Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ceph RADOS Gateway bucket index garbage collection
#!/bin/bash
#
# Find orphaned bucket index objects in the RGW bucket index pool
# and clean them up if they do not belong to a bucket
#
# Author: Wido den Hollander <wido@42on.com>
#
INDEX_POOL=$1
if [ -z "$INDEX_POOL" ]; then
echo "Usage: $0 <index pool>"
exit 1
fi
INDEXES=$(mktemp)
METADATA=$(mktemp)
trap "rm -f ${INDEXES} ${METADATA}" EXIT
radosgw-admin metadata list bucket.instance|jq -r '.[]' > ${METADATA}
rados -p ${INDEX_POOL} ls > $INDEXES
for OBJECT in $(cat ${INDEXES}); do
MARKER=$(echo ${OBJECT}|cut -d '.' -f 3,4,5)
grep ${MARKER} ${METADATA} > /dev/null
if [ "$?" -ne 0 ]; then
echo $OBJECT
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.