Skip to content

Commit 081ec69

Browse files
committed
Abort node initialization if cloud taint was already removed
If node events are received at a faster rate than they can be processed then initialization for some nodes will be delayed. Once they are eventually processed their cloud taint is removed, but there may already be several update events for those nodes with the cloud taint still on them already in the event queue. To avoid re-initializing those nodes, the cloud taint is checked for again after requesting the current state of the node. If the cloud taint is no longer on the node then nil is returned from the RetryOnConflict, as an error does not need to be logged. The logging for a successful initialization is also moved inside the RetryOnConflict so that the early nil return does not cause the aborted initialization to be logged as a success.
1 parent ed239ce commit 081ec69

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/controller/cloud/node_controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ func (cnc *CloudNodeController) initializeNode(node *v1.Node) {
256256
return err
257257
}
258258

259+
cloudTaint := getCloudTaint(curNode.Spec.Taints)
260+
if cloudTaint == nil {
261+
// Node object received from event had the cloud taint but was outdated,
262+
// the node has actually already been initialized.
263+
return nil
264+
}
265+
259266
if curNode.Spec.ProviderID == "" {
260267
providerID, err := cloudprovider.GetInstanceProviderID(context.TODO(), cnc.cloud, types.NodeName(curNode.Name))
261268
if err == nil {
@@ -312,14 +319,14 @@ func (cnc *CloudNodeController) initializeNode(node *v1.Node) {
312319
// After adding, call UpdateNodeAddress to set the CloudProvider provided IPAddresses
313320
// So that users do not see any significant delay in IP addresses being filled into the node
314321
cnc.updateNodeAddress(curNode, instances)
322+
323+
klog.Infof("Successfully initialized node %s with cloud provider", node.Name)
315324
return nil
316325
})
317326
if err != nil {
318327
utilruntime.HandleError(err)
319328
return
320329
}
321-
322-
klog.Infof("Successfully initialized node %s with cloud provider", node.Name)
323330
}
324331

325332
func getCloudTaint(taints []v1.Taint) *v1.Taint {

0 commit comments

Comments
 (0)