Fix create delete infinite loop#373
Conversation
1b709ef to
971d514
Compare
Observe was returning ResourceExists:false for disabled buckets with empty atProvider.backends, causing the Crossplane reconciler to invoke Create (and write three etcd annotations) on every cycle. Return ResourceExists:true,ResourceUpToDate:true instead, and drive the condition to Unavailable on first observe so subsequent reconciles are no-ops.
50a55f3 to
fe3bc03
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes an edge case in the Bucket controller’s Observe path where a disabled Bucket CR with no status backends could be repeatedly treated as “needs create,” causing Crossplane to continuously write the external-create-pending annotation and requeue (an etcd write loop). The change treats this specific disabled/no-backends/non-deleting scenario as “externally existing and up-to-date” to stop create attempts, and adds a focused regression test.
Changes:
- Update
Observeto returnResourceExists: true(andResourceUpToDate: true) for disabled buckets that have no backends and are not being deleted. - Add a regression test covering the disabled/no-backends behavior and a control case for non-disabled buckets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/controller/bucket/observe.go |
Adds an early-return edge case so disabled buckets with empty status backends don’t trigger Crossplane create-pending loops. |
internal/controller/bucket/observe_test.go |
Adds a dedicated test ensuring Observe reports ResourceExists:true for the disabled/no-backends case and preserves existing behavior for enabled buckets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #373 +/- ##
==========================================
+ Coverage 28.58% 28.95% +0.37%
==========================================
Files 60 60
Lines 5577 5598 +21
==========================================
+ Hits 1594 1621 +27
+ Misses 3899 3894 -5
+ Partials 84 83 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description of your changes
This pull request addresses an edge case in the S3 bucket controller where disabled buckets with no backends could cause an infinite etcd write loop. The main change ensures that such buckets are treated as "existing" to prevent unnecessary create operations, and a dedicated test is added to verify this behavior.
Bugfix to prevent etcd write loops for disabled buckets:
Observelogic inobserve.goto returnResourceExists: truefor disabled buckets with no backends, preventing repeated and unnecessary create attempts that could fill up etcd.Test coverage improvements:
TestObserveDisabledBucketNoBackendsDoesNotTriggerCreateinobserve_test.goto prove that the fix prevents the etcd write loop by ensuringResourceExists: trueis returned in this scenario.runtimeandfakeclient to support new testsI have:
make ready-for-reviewto ensure this PR is ready for review.make ceph-chainsawto validate these changes against Ceph. This step is not always necessary. However, for changes related to S3 calls it is sensible to validate against an actual Ceph cluster. Localstack is used in our CI Chainsaw suite for convenience and there can be disparity in S3 behaviours between it and Ceph. Seedocs/TESTING.mdfor information on how to run tests against a Ceph cluster.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Existing CI