]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: allow rgw-orphan-list to note when rados objects are in namespace 37572/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 6 Oct 2020 19:21:02 +0000 (15:21 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 7 Oct 2020 12:51:50 +0000 (08:51 -0400)
Currently namespaces and locators are ignored when `rados ls` is run
by rgw-orphan-list to record RADOS's known objects.

However there have been cases where RADOS objects have a locator, and
when one is included in the listing, the script does not handle it
correctly. Now when objects have locators, we will prevent their
output from entering the .intermediate file.

Additionally we do not expect RGW data objects to be in RADOS
namespaces, so when a namespaced object is detected, we'll error out
with a message.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/rgw/rgw-orphan-list

index bdb0a43ac118117f2482c0b42b77039a0b252de2..1ebd60c719d131b4c4983a276a693c7624802900 100755 (executable)
@@ -18,6 +18,9 @@ delta_out="${out_dir}/orphan-list-${timestamp}.out"
 
 error_out() {
     echo "An error was encountered while running '$1'. Aborting."
+    if [ $# -gt 2 ] ;then
+       echo "Error: $3"
+    fi
     if [ $# -gt 1 ] ;then
        echo "Review file '$2' for details."
     fi
@@ -54,10 +57,21 @@ echo "Pool is \"$pool\"."
 echo "Note: output files produced will be tagged with the current timestamp -- ${timestamp}."
 
 echo "running 'rados ls' at $(date)"
-rados ls --pool="$pool" >"$rados_out" 2>"$rados_err"
+rados ls --pool="$pool" --format=json-pretty --all >"$rados_out" 2>"$rados_err"
 if [ "$?" -ne 0 ] ;then
     error_out "rados ls" "$rados_err"
 fi
+
+# check for namespaces and error out if any found
+grep '^[[:blank:]]*"namespace":' "$rados_out" | grep --silent '[^:]*: "[^"]'
+if [ "${PIPESTATUS[1]}" -eq 0 ] ;then
+    error_out "rados ls" "$rados_out" "Found one or more RADOS objects existing in a namespace."
+fi
+
+# move from json to list of oids
+grep '^[[:blank:]]*"name":' "$rados_out" | sed 's/[^:]*: "\(.*\)"$/\1/' >"$temp_file"
+mv -f "$temp_file" "$rados_out"
+
 sort -u "$rados_out" >"$temp_file"
 mv -f "$temp_file" "$rados_out"