in pkg/node/manager/manager.go [419:467]
func (m *manager) performAsyncOperation(job interface{}) (ctrl.Result, error) {
asyncJob, ok := job.(AsyncOperationJob)
if !ok {
m.Log.Error(fmt.Errorf("wrong job type submitted"), "not re-queuing")
return ctrl.Result{}, nil
}
log := m.Log.WithValues("node", asyncJob.nodeName, "operation", asyncJob.op)
var err error
switch asyncJob.op {
case Init:
utils.SendNodeEventWithNodeName(m.wrapper.K8sAPI, asyncJob.nodeName, utils.VersionNotice, fmt.Sprintf("The node is managed by VPC resource controller version %s", m.controllerVersion), v1.EventTypeNormal, m.Log)
err = asyncJob.node.InitResources(m.resourceManager)
if err != nil {
if pauseHealthCheckOnError(err) && !m.SkipHealthCheck() {
m.setStopHealthCheck()
log.Info("node manager sets a pause on health check due to observing a EC2 error", "error", err.Error())
}
log.Error(err, "removing the node from cache as it failed to initialize")
m.removeNodeSafe(asyncJob.nodeName)
// if initializing node failed, we want to make this visible although the manager will retry
// the trunk label will stay as false until retry succeed
// Node will be retried for init on next event
return ctrl.Result{}, nil
}
// If there's no error, we need to update the node so the capacity is advertised
asyncJob.op = Update
return m.performAsyncOperation(asyncJob)
case Update:
err = asyncJob.node.UpdateResources(m.resourceManager)
case Delete:
err = asyncJob.node.DeleteResources(m.resourceManager)
default:
m.Log.V(1).Info("no operation operation requested",
"node", asyncJob.nodeName)
return ctrl.Result{}, nil
}
if err == nil {
log.V(1).Info("successfully performed node operation")
return ctrl.Result{}, nil
}
log.Error(err, "failed to perform node operation")
return ctrl.Result{}, nil
}