Skip to content

Commit aa3accd

Browse files
committed
fix(backupstrategy-controller): stop the default-objects gate looping when velero.bslEnabled=false
The cozy-default BackupClass routes VMInstance/VMDisk to the Velero Strategy CRs unconditionally, but the chart gates those CRs on velero.bslEnabled. With the BSL disabled they never render, so the gate counted them as permanently missing and forced a Helm upgrade every MinForceInterval forever, climbing force_reconciles_total and pinning the missing gauge. Skip Velero-kind strategyRefs when the BSL is disabled (empty VeleroNamespace), the same flag that gates their render. The regression test now omits the manually-created Velero objects so it fails without the skip. Correct the values.yaml comment that wrongly claimed the Strategy CRs still ship in this mode. Signed-off-by: IvanHunters <[email protected]>
1 parent e85501e commit aa3accd

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎internal/backupcontroller/default_objects_gate.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@ func (g *DefaultObjectsGate) missingObjects(ctx context.Context, backupClass *ba
329329
if strategy.StrategyRef.APIGroup != nil && *strategy.StrategyRef.APIGroup != "" {
330330
group = *strategy.StrategyRef.APIGroup
331331
}
332+
// When the Velero BSL is disabled (velero.bslEnabled=false, surfaced
333+
// here as an empty VeleroNamespace) the chart gates the Velero
334+
// Strategy CRs off the SAME flag, so they are never rendered. The
335+
// BackupClass still routes to them unconditionally, so counting them
336+
// as missing would force a Helm upgrade every MinForceInterval
337+
// forever against a render that can never produce them.
338+
if g.VeleroNamespace == "" && group == strategyAPIGroup && kind == "Velero" {
339+
continue
340+
}
332341
key := fmt.Sprintf("%s/%s", kind, name)
333342
if _, dup := seen[key]; dup {
334343
continue

‎internal/backupcontroller/default_objects_gate_test.go‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,21 @@ func TestMissingObjectsIgnoresUnmappedKinds(t *testing.T) {
383383
}
384384
}
385385

386-
// TestMissingObjectsSkipsBSLWhenVeleroNamespaceEmpty covers
387-
// velero.bslEnabled=false: the chart renders no BSL, so its absence is not
388-
// a defect and must not drive forced upgrades.
389-
func TestMissingObjectsSkipsBSLWhenVeleroNamespaceEmpty(t *testing.T) {
386+
// TestMissingObjectsSkipsVeleroWhenNamespaceEmpty covers
387+
// velero.bslEnabled=false: the chart gates BOTH the BSL and the Velero
388+
// Strategy CRs off the same flag, so neither is rendered and their absence
389+
// is not a defect. The BackupClass still routes to the Velero strategies
390+
// unconditionally, which is the trap: without the skip the gate would count
391+
// the never-rendered Velero CRs as missing and force a Helm upgrade every
392+
// MinForceInterval forever. The Velero objects are deliberately NOT
393+
// pre-created here, because with the BSL disabled the chart never renders
394+
// them on a real cluster.
395+
func TestMissingObjectsSkipsVeleroWhenNamespaceEmpty(t *testing.T) {
390396
bc := cozyDefaultBackupClass()
391397
g, _ := newGate(t, []client.Object{sourceSecret("b"), bc},
392398
helmReleaseObject(),
393399
strategyObject("CNPG", "cozy-default-cnpg"),
394400
strategyObject("Etcd", "cozy-default-etcd"),
395-
strategyObject("Velero", "cozy-default-velero-vminstance"),
396-
strategyObject("Velero", "cozy-default-velero-vmdisk"),
397401
)
398402
g.VeleroNamespace = ""
399403

@@ -402,7 +406,7 @@ func TestMissingObjectsSkipsBSLWhenVeleroNamespaceEmpty(t *testing.T) {
402406
t.Fatalf("missingObjects: %v", err)
403407
}
404408
if len(missing) != 0 {
405-
t.Fatalf("missing = %v, want none when the BSL is disabled", missing)
409+
t.Fatalf("missing = %v, want none when Velero is disabled", missing)
406410
}
407411
}
408412

‎packages/system/backupstrategy-controller/values.yaml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,13 @@ backupStorage:
157157
# DefaultObjectsGate has forced a real Helm upgrade (an interval reconcile
158158
# alone does not re-render). Setting this
159159
# to false is an explicit opt-out for clusters that disable VM backups
160-
# entirely and want to avoid the cluster-default BSL — in that case the
161-
# cozy-default-velero-vminstance / -vmdisk strategy CRs still ship but
162-
# their `storageLocation: cozy-default` reference will not resolve, so
163-
# VM BackupJobs against cozy-default will fail.
160+
# entirely and want to avoid the cluster-default BSL. In that case the
161+
# cozy-default-velero-vminstance / -vmdisk Strategy CRs are gated off the
162+
# same flag and are NOT rendered either, so the DefaultObjectsGate does
163+
# not expect them (it would otherwise force a Helm upgrade forever against
164+
# a render that can never produce them). VM BackupJobs against cozy-default
165+
# still fail, because the BackupClass keeps routing VMInstance / VMDisk to
166+
# those absent strategies.
164167
velero:
165168
bslEnabled: true
166169
namespace: cozy-velero

0 commit comments

Comments
 (0)