Support adopting existing radosgw buckets and users #5
Reference in New Issue
Block a user
Delete Branch "benvin/safe-adoption"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The operator assumed it created every user/bucket it managed, so taking over pre-existing radosgw state was unsafe: reconciling an existing user could overwrite its attributes, reconciling an existing bucket wiped its policy, and deleting a CRD always deleted the underlying RGW object (only
BuckethadretainOnDelete). This makes adoption first-class — take over in place, and hand back without destroying anything.Answers the questions from the request: creating CRDs for existing resources is now a safe noop on existence (keys reused, policy preserved), and deletion can orphan instead of destroy.
Changes
retainOnDeleteadded toObjectStoreUserandBucketAccess(dedicated users), symmetric withBucket. Deleting the CRD drops the finalizer and leaves the RGW object.cephrgwop*Sidand now merges: it preserves statements it does not own and reconciles only its own (MergeBucketPolicy+GetBucketPolicy). Adopting a bucket with a hand-written policy keeps it. NewBucket.spec.managePolicy(defaulttrue) opts out of policy management entirely. Legacy (unprefixed) operator sids are still recognised so upgrades don't duplicate statements.DisplayNameonly sent when non-empty;suspendedis now an optional*bool(unset = leave as-is).maxBucketsstill defaults to 1000 (documented as an adoption consideration).status.adopted(+ADOPTEDprintcolumn) onObjectStoreUser/Bucket, true when the RGW object pre-existed. Detection is keyed off the status identity field so aPendingowner-wait doesn't mislabel it.docs/adoption.md+config/samples/05-adoption.yaml; cover merge/foreign-preservation/idempotence inpolicy_test.go.Reserved statement ids
The
cephrgwopprefix (and legacyfull/custom/raw/readonly*/readwrite*) are treated as operator-owned — don't name your own policy statements with them. Documented indocs/adoption.md.Verification
gofmt,go vet,go build ./...,go test -race ./...pass;CGO_ENABLED=0binary builds; CRDs regenerated with controller-gen v0.17.3.https://claude.ai/code/session_016CEncETbf8cvy1PhsHfFHM