File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const (
2727 informerResyncPeriod = 1 * time .Minute
2828 defaultMetadataTTL = 300 * time .Second
2929 defaultK8sNodeCacheTTL = 300 * time .Second
30+ listNodeContextTimeout = 30 * time .Second
3031)
3132
3233var registeredK8sNodeCache * k8sNodeCache = newK8sNodeCache ()
@@ -68,7 +69,10 @@ func (c *k8sNodeCache) updateCache(kubeclient kubernetes.Interface) {
6869 return
6970 }
7071
71- nodeList , err := kubeclient .CoreV1 ().Nodes ().List (context .TODO (), metav1.ListOptions {})
72+ ctx , cancel := context .WithTimeout (context .Background (), listNodeContextTimeout )
73+ defer cancel ()
74+
75+ nodeList , err := kubeclient .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {})
7276 if err != nil {
7377 klog .Errorf ("failed to list nodes, cannot create/update k8s node cache: %s" , err )
7478 return
You can’t perform that action at this time.
0 commit comments