Skip to content

Commit

Permalink
feat: node update should trigger metadata update
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur-akamai committed Jan 4, 2024
1 parent 053f6d6 commit 3797e68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cloud/linode/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
23 changes: 16 additions & 7 deletions cloud/linode/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
})
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3797e68

Please sign in to comment.