diff --git a/pkg/applyinator/applyinator.go b/pkg/applyinator/applyinator.go index 6c94d62d..b25ead2e 100644 --- a/pkg/applyinator/applyinator.go +++ b/pkg/applyinator/applyinator.go @@ -45,6 +45,9 @@ type Plan struct { OneTimeInstructions []OneTimeInstruction `json:"instructions,omitempty"` Probes map[string]prober.Probe `json:"probes,omitempty"` PeriodicInstructions []PeriodicInstruction `json:"periodicInstructions,omitempty"` + // ResetFailureCountOnStartup denotes whether the system-agent should reset the failure count + // and applied-checksum for plans that are force applied each time the system-agent starts. + ResetFailureCountOnStartup bool `json:"resetFailureCountOnStartup,omitempty"` } type CommonInstruction struct { diff --git a/pkg/k8splan/watcher.go b/pkg/k8splan/watcher.go index 4ecdc069..687687a6 100644 --- a/pkg/k8splan/watcher.go +++ b/pkg/k8splan/watcher.go @@ -215,6 +215,12 @@ func (w *watcher) start(ctx context.Context, strictVerify bool) { logrus.Infof("Detected first start, force-applying one-time instruction set") needsApplied = true hasRunOnce = true + // Plans which have previously succeeded but need to be force applied + // should continue to respect the specified failure count. + if cp.Plan.ResetFailureCountOnStartup { + secret.Data[appliedChecksumKey] = []byte("") + secret.Data[failureCountKey] = []byte("0") + } } // Check to see if we've exceeded our failure count threshold