chore: improve controllers dataprotection coverage - #10381
Conversation
|
Auto Cherry-pick Instructions CLA Recheck Instructions |
84930da to
c6ffb32
Compare
|
/approve |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10381 +/- ##
==========================================
+ Coverage 53.26% 57.02% +3.76%
==========================================
Files 533 533
Lines 63529 63541 +12
==========================================
+ Hits 33839 36235 +2396
+ Misses 26249 23864 -2385
- Partials 3441 3442 +1
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:
|
|
|
||
| deletable, err := reconciler.isBackupDeletable(reqCtx, pendingBackup) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(deletable).To(BeTrue()) |
There was a problem hiding this comment.
[P1] Do not codify running backups as GC-deletable. A normal Backup gets status.expiration when it moves to Running, so a run that exceeds its retention period can reach this path and be deleted by GC before it completes, including its backup Job/StatefulSet. Retention should only expire terminal backups, or an explicitly failed/stale state with a separate contract; this test locks in a data-protection behavior that can interrupt an in-flight backup.
c6ffb32 to
bcd11a4
Compare
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: cluster.Namespace, | ||
| Name: "component-account", | ||
| Labels: constant.GetCompLabels(cluster.Name, testdp.ComponentName), |
There was a problem hiding this comment.
[P1] This fixture only has generic cluster/component labels plus username/password data, but the test expects it to be captured as a system account. That locks in the current broad matching in setEncryptedSystemAccountsAnnotation: any cluster-labeled Secret with those two keys is copied into the Backup annotation and can later be restored as a system-account Secret, which can capture unrelated credentials. Please require an explicit system-account identity (for example the system-account label/name/spec) and add a negative case for ordinary cluster Secrets carrying username/password.
bcd11a4 to
0051608
Compare
|
/approve |
| usernameKey := constant.AccountNameForSecret | ||
| passwordKey := constant.AccountPasswdForSecret | ||
| isSystemAccountSecret := func(secret *corev1.Secret) bool { | ||
| if secret.Labels[systemAccountSecretLabel] == "" { |
There was a problem hiding this comment.
[P1] This label gate drops real sharding system-account Secrets from the backup annotation. The sharding account transformer creates those Secrets with the cluster/sharding labels and username/password data, but it does not add apps.kubeblocks.io/system-account; the new test manually adds that label to the sharding fixture, so it does not exercise the real generated Secret shape. As a result, sharded-cluster backups stop preserving sharding account passwords, and restore can recreate or leave system-account Secrets whose passwords do not match the restored database accounts. The fix needs to either add this explicit system-account identity in the real sharding account generation path before relying on the label, or keep a precise sharding-account identification path and cover that generated Secret shape in the test.
0051608 to
3e4abec
Compare
|
/approve |
Summary
Coverage
Production Code Changes
GCReconciler.isBackupDeletablenow returns false for non-terminal backup phases such as Running.status.expirationwhile still Running.setEncryptedSystemAccountsAnnotationnow requires an explicit system-account identity before capturing credentials: component Secrets use theapps.kubeblocks.io/system-accountlabel, and sharding Secrets must match the real generated<cluster>-<sharding>-<account>Secret name with sharding labels.Tests