Skip to content

[fix] : add context timeout when making listNodes k8s call #361

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

Merged
merged 1 commit into from
Mar 26, 2025
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
6 changes: 5 additions & 1 deletion cloud/linode/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
informerResyncPeriod = 1 * time.Minute
defaultMetadataTTL = 300 * time.Second
defaultK8sNodeCacheTTL = 300 * time.Second
listNodeContextTimeout = 30 * time.Second
)

var registeredK8sNodeCache *k8sNodeCache = newK8sNodeCache()
Expand Down Expand Up @@ -68,7 +69,10 @@ func (c *k8sNodeCache) updateCache(kubeclient kubernetes.Interface) {
return
}

nodeList, err := kubeclient.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
ctx, cancel := context.WithTimeout(context.Background(), listNodeContextTimeout)
defer cancel()

nodeList, err := kubeclient.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
klog.Errorf("failed to list nodes, cannot create/update k8s node cache: %s", err)
return
Expand Down
Loading