fix: wait before recreating restore account secrets#10575
Conversation
|
Auto Cherry-pick Instructions CLA Recheck Instructions |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10575 +/- ##
==========================================
+ Coverage 63.63% 63.66% +0.03%
==========================================
Files 519 519
Lines 62849 62836 -13
==========================================
+ Hits 39992 40005 +13
+ Misses 19235 19218 -17
+ Partials 3622 3613 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Runtime validation for the production change was already completed by the original Valkey reporter/test owner. Validated production commit: The current PR head Focused validation:
Evidence:
Boundary: this validates removal of the account-Secret deletion/recreation blocker for this focused scenario. It is not a claim that sharded datafile restore is supported or that the full release suite is ready. |
| constant.AccountNameForSecret: []byte(accountName), | ||
| constant.AccountPasswdForSecret: password, | ||
| }, | ||
| if controllerutil.RemoveFinalizer(secret, constant.DBClusterFinalizerName) { |
There was a problem hiding this comment.
[P1] DataProtection must not remove an Apps-owned finalizer to force replacement of this Secret. This already fails for component-owned account Secrets, which carry component.kubeblocks.io/finalizer rather than this cluster finalizer and therefore remain Terminating forever. Teaching DP about that second finalizer would deepen the same ownership violation. Secret replacement needs an explicit API and ownership contract with the Apps controller; it must not depend on or bypass Apps internal finalizer implementations.
| } | ||
| if err := r.Client.Create(reqCtx.Ctx, secret); err != nil { | ||
| uid := secret.UID | ||
| if err := r.Client.Delete(reqCtx.Ctx, secret, client.Preconditions{UID: &uid}); err != nil && !apierrors.IsNotFound(err) { |
There was a problem hiding this comment.
[P2] The UID precondition protects a newly created same-name Secret, but the resulting Conflict does not guarantee convergence. This ordinary error is treated as a successful reconcile by the outer handler once the PVC has its existing condition, and the controller does not watch Secret changes. A cached stale object, UID mismatch, or create race can therefore leave restoration stopped after preserving the replacement. Handle these identity races as an explicit requeue or converged replacement state, and test the complete outer reconcile path.
Fixes #10574.
What changed
cluster.kubeblocks.io/finalizer, and an already deletion-stamped sharding secret.Why
For sharded restore, the apps controller can create an immutable generated sharding account secret before DataProtection restores the backed-up credential. If DataProtection deletes that immutable secret and immediately creates the same name, Kubernetes can keep the old object in Terminating due to the cluster finalizer, causing repeated
object is being deleted ... already existserrors and blocking PVC restore.Validation
make test-go-generatego test ./controllers/dataprotection -run 'TestRestoreSystemAccountSecrets|Test.*SystemAccountSecret'Boundary
go test ./controllers/dataprotectiondid not run locally because envtest cannot start:/usr/local/kubebuilder/bin/etcdis missing on this machine.