Skip to content

Commit

Permalink
Mark perform-check and recover-check as "pending" (not prunable)
Browse files Browse the repository at this point in the history
This is because they may be long-lived
  • Loading branch information
benhoyt committed Apr 11, 2024
1 parent 62e34c1 commit ba102f8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internals/overlord/checkstate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package checkstate

// TODO: should it only go to recover-check when it hits the threshold?

import (
"context"
"sort"
Expand All @@ -24,6 +26,10 @@ import (
"github.com/canonical/pebble/internals/plan"
)

const (
noPruneAttr = "checkstate-no-prune"
)

// CheckManager starts and manages the health checks.
type CheckManager struct {
state *state.State
Expand All @@ -47,6 +53,10 @@ func NewManager(s *state.State, runner *state.TaskRunner) *CheckManager {
state: s,
checks: make(map[string]*checkData),
}
// Health check changes can be long-running; ensure they don't get pruned.
s.RegisterPendingChangeByAttr(noPruneAttr, func(change *state.Change) bool {
return true
})
runner.AddHandler("perform-check", manager.doPerformCheck, nil)
runner.AddHandler("recover-check", manager.doRecoverCheck, nil)
return manager
Expand Down Expand Up @@ -101,13 +111,15 @@ func (m *CheckManager) PlanChanged(newPlan *plan.Plan) {
func (m *CheckManager) performCheckChange(config *plan.Check) (changeID string) {
task := performCheck(m.state, config.Name, checkType(config))
change := m.state.NewChange("perform-check", task.Summary())
change.Set(noPruneAttr, true)
change.AddTask(task)
return change.ID()
}

func (m *CheckManager) recoverCheckChange(config *plan.Check) (changeID string) {
task := recoverCheck(m.state, config.Name, checkType(config))
change := m.state.NewChange("recover-check", task.Summary())
change.Set(noPruneAttr, true)
change.AddTask(task)
return change.ID()
}
Expand Down

0 comments on commit ba102f8

Please sign in to comment.