node-controller reconcile node labels on each update

instead of waiting for the periodic loop of the node-controller to
go through all the nodes, use the sync logic to reconcile the node
labels each time that the node has changed after it has been
initialized.

This has the benefit that changes by external entities on this labels
are quickly reconciled.

Change-Id: I45cfc1e3f0b9eefdfdd67267229420d76132ab87
This commit is contained in:
Antonio Ojea 2024-02-17 18:56:14 +00:00
parent 03bd3e25b1
commit 0ab006b8a1

View File

@ -283,11 +283,6 @@ func (cnc *CloudNodeController) UpdateNodeStatus(ctx context.Context) error {
}
cnc.updateNodeAddress(ctx, node, instanceMetadata)
err = cnc.reconcileNodeLabels(node.Name)
if err != nil {
klog.Errorf("Error reconciling node labels for node %q, err: %v", node.Name, err)
}
}
workqueue.ParallelizeUntil(ctx, int(cnc.workerCount), len(nodes), updateNodeFunc)
@ -423,9 +418,8 @@ func (cnc *CloudNodeController) syncNode(ctx context.Context, nodeName string) e
cloudTaint := getCloudTaint(curNode.Spec.Taints)
if cloudTaint == nil {
// Node object received from event had the cloud taint but was outdated,
// the node has actually already been initialized, so this sync event can be ignored.
return nil
// Node object was already initialized, only need to reconcile the labels
return cnc.reconcileNodeLabels(nodeName)
}
klog.Infof("Initializing node %s with cloud provider", nodeName)