mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
rgw: allow rgw-orphan-list to note when rados objects are in namespace
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>
This commit is contained in:
parent
935359d8b9
commit
ddf52016fa
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user