Skip to content

Commit

Permalink
Merge pull request #201 from HarrisonWAffel/retries-after-restart
Browse files Browse the repository at this point in the history
Add ResetFailureCountOnServiceRestart
  • Loading branch information
HarrisonWAffel authored Oct 17, 2024
2 parents 7ad21ff + fb4a027 commit b8c28d0
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 b8c28d0

Please sign in to comment.