From c423be11d5e4cf967f79988fbc2245f29e758dd8 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 14 Feb 2018 15:20:34 -0500 Subject: [PATCH] Process existing cloud nodes in CCM Existing nodes are sent via update and not via the add function, so let's add an UpdateCloudNode and just forward it to the AddCloudNode. This works fine as all we do is look for the cloud taint and bail out if it is not present. --- pkg/controller/cloud/node_controller.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/controller/cloud/node_controller.go b/pkg/controller/cloud/node_controller.go index 9f1c86e7b94..44b793e9f09 100644 --- a/pkg/controller/cloud/node_controller.go +++ b/pkg/controller/cloud/node_controller.go @@ -98,8 +98,11 @@ func NewCloudNodeController( nodeStatusUpdateFrequency: nodeStatusUpdateFrequency, } - nodeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: cnc.AddCloudNode, + // Use shared informer to listen to add/update of nodes. Note that any nodes + // that exist before node controller starts will show up in the update method + cnc.nodeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: cnc.AddCloudNode, + UpdateFunc: cnc.UpdateCloudNode, }) return cnc @@ -277,6 +280,14 @@ func (cnc *CloudNodeController) MonitorNode() { } } +func (cnc *CloudNodeController) UpdateCloudNode(_, newObj interface{}) { + if _, ok := newObj.(*v1.Node); !ok { + utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", newObj)) + return + } + cnc.AddCloudNode(newObj) +} + // This processes nodes that were added into the cluster, and cloud initialize them if appropriate func (cnc *CloudNodeController) AddCloudNode(obj interface{}) { node := obj.(*v1.Node)