in pkg/controller/manager.go [278:317]
func (am *actionManager) intentFor(node intent.Input) *intent.Intent {
in := intent.Given(node)
log := am.log.WithFields(logfields.Intent(in))
if in.Stuck() {
reset := in.Reset()
log.WithField("intent-reset", reset.DisplayString()).Debug("node intent indicates stuck")
log.Warn("stabilizing stuck node")
return reset
}
// TODO: add per-node bucketed backoff for error handling and retries.
if in.Errored() {
log.Debug("intent errored")
log.Warn("action errored on node, resetting to stabilize")
in = in.Reset()
return in.Projected()
}
next := in.Projected()
if (in.Actionable() || next.Actionable()) && in.Realized() && !in.InProgress() {
log.Debug("intent needs action")
log.Debug("needs action towards next step")
return next
}
if !in.Realized() {
log.Debug("intent is not yet realized")
return nil
}
if successfulUpdate(in) {
return in
}
if in.HasUpdateAvailable() && in.Waiting() && !in.Errored() {
log.Debug("intent starts update")
return in.SetBeginUpdate()
}
log.Debug("no action needed")
return nil
}