diff --git a/cloud/linode/annotations.go b/cloud/linode/annotations.go index 70e93855..a4185e2f 100644 --- a/cloud/linode/annotations.go +++ b/cloud/linode/annotations.go @@ -29,5 +29,5 @@ const ( annLinodeCloudFirewallID = "service.beta.kubernetes.io/linode-loadbalancer-firewall-id" annLinodeNodePrivateIP = "node.k8s.linode.com/private-ip" - annLinodeUUID = "node.k8s.linode.com/uuid" + annLinodeHostUUID = "node.k8s.linode.com/host-uuid" ) diff --git a/cloud/linode/node_controller.go b/cloud/linode/node_controller.go index fba6c6f0..5834d196 100644 --- a/cloud/linode/node_controller.go +++ b/cloud/linode/node_controller.go @@ -43,7 +43,16 @@ func (s *nodeController) Run(stopCh <-chan struct{}) { return } - klog.Infof("NodeController will handle node (%s) metadata", node.Name) + klog.Infof("NodeController will handle newly created node (%s) metadata", node.Name) + s.queue.Add(node) + }, + UpdateFunc: func(_, new interface{}) { + node, ok := new.(*v1.Node) + if !ok { + return + } + + klog.Infof("NodeController will handle updated node (%s) metadata", node.Name) s.queue.Add(node) }, }) @@ -52,14 +61,14 @@ func (s *nodeController) Run(stopCh <-chan struct{}) { s.informer.Informer().Run(stopCh) } -// worker runs a worker thread that dequeues deleted services and processes -// deleting their underlying NodeBalancers. +// worker runs a worker thread that dequeues new or modified nodes and processes +// metadata (host UUID) on each of them. func (s *nodeController) worker() { - for s.processNextAddition() { + for s.processNext() { } } -func (s *nodeController) processNextAddition() bool { +func (s *nodeController) processNext() bool { key, quit := s.queue.Get() if quit { return false @@ -98,12 +107,12 @@ func (s *nodeController) handleNodeAdded(ctx context.Context, node *v1.Node) err return err } - uuid, ok := node.Labels[annLinodeUUID] + uuid, ok := node.Labels[annLinodeHostUUID] if ok && uuid == linode.HostUUID { return nil } - node.Labels[annLinodeUUID] = linode.HostUUID + node.Labels[annLinodeHostUUID] = linode.HostUUID _, err = s.kubeclient.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{}) if err != nil {