Skip to content

Instantly share code, notes, and snippets.

@wido
Created November 15, 2018 12:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wido/6650e66b09770ef02df89636891bef04 to your computer and use it in GitHub Desktop.
Save wido/6650e66b09770ef02df89636891bef04 to your computer and use it in GitHub Desktop.
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