Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap node update in retry #175

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cloud/linode/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
v1informers "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/retry"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -139,10 +140,23 @@ func (s *nodeController) handleNode(ctx context.Context, node *v1.Node) error {
return nil
}

node.Labels[annLinodeHostUUID] = linode.HostUUID
if err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
// Get a fresh copy of the node so the resource version is up to date
n, err := s.kubeclient.CoreV1().Nodes().Get(ctx, node.Name, metav1.GetOptions{})
if err != nil {
return err
}

_, err = s.kubeclient.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{})
if err != nil {
// It may be that the UUID has been set
if n.Labels[annLinodeHostUUID] == linode.HostUUID {
return nil
}

// Try to update the node
n.Labels[annLinodeHostUUID] = linode.HostUUID
_, err = s.kubeclient.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{})
return err
}); err != nil {
klog.Infof("node update error: %s", err.Error())
return err
}
Expand Down
Loading