Skip to content

Commit

Permalink
Add ResetFailureCountOnServiceRestart, if true reset plan failure cou…
Browse files Browse the repository at this point in the history
…nt after each restart of the system-agent
  • Loading branch information
HarrisonWAffel committed Oct 16, 2024
1 parent 41d32d7 commit fb4a027
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/applyinator/applyinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/k8splan/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb4a027

Please sign in to comment.