in pkg/agent/agent.go [408:455]
func (a *Agent) checkNodePreflight() error {
// TODO: Run a check of the Node Resource and reset appropriately
// TODO: Inform controller for taint removal
a.log.Debug("preflight check")
n, err := a.kube.CoreV1().Nodes().Get(context.TODO(), a.nodeName, v1meta.GetOptions{})
if err != nil {
return errors.WithMessage(err, "unable to retrieve Node for preflight check")
}
// Update our state to be "ready" for action, this shouldn't actually do so
// unless its really done.
in := intent.Given(n)
log := a.log.WithField("init-intent", in.DisplayString())
// TODO: check that we're properly reseting, for now its not needed to mark
// our work "done"
switch {
case in.Terminal(): // we're at a terminating point where there's no progress to make.
in.State = marker.NodeStateReady
log.Debug("in terminal state: ready")
case in.Waiting():
// already in a holding pattern, no need to re-prime ourselves in
// preflight.
log.Debug("in waiting state")
case in.Wanted == "", in.Active == "":
in = in.Reset()
log.Debug("in inconsistent state; resetting")
default:
// there's not a good way to re-prime ourselves in the prior state.
in = in.Reset()
log.Debug("repriming state")
}
log.WithField("preflight-intent", in.DisplayString()).
Debug("preflight complete")
err = a.poster.Post(in)
if err != nil {
log.WithError(err).Error("could not update intent status")
return err
}
return nil
}