Skip to content

Commit fba1fea

Browse files
authored
Merge pull request #1373 from dougbtv/livequery-context
adds context to GetPodAPILiveQuery
2 parents fc72ddb + f186370 commit fba1fea

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pkg/k8sclient/k8sclient.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func (c *ClientInfo) GetPodContext(ctx context.Context, namespace, name string)
9292
}
9393

9494
// GetPodAPILiveQuery does a live API query for the pod, instead of using informers, for cases when a failure occurred, as to prevent a cache miss.
95-
func (c *ClientInfo) GetPodAPILiveQuery(namespace, name string) (*v1.Pod, error) {
96-
return c.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
95+
func (c *ClientInfo) GetPodAPILiveQuery(ctx context.Context, namespace, name string) (*v1.Pod, error) {
96+
return c.Client.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
9797
}
9898

9999
// DeletePod deletes a pod from kubernetes

pkg/multus/multus.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,9 @@ func GetPod(kubeClient *k8s.ClientInfo, k8sArgs *types.K8sArgs, isDel bool) (*v1
558558
// Try one more time to get the pod directly from the apiserver;
559559
// TODO: figure out why static pods don't show up via the informer
560560
// and always hit this case.
561-
pod, err = kubeClient.GetPodAPILiveQuery(podNamespace, podName)
561+
ctx, cancel := context.WithTimeout(context.TODO(), pollDuration)
562+
defer cancel()
563+
pod, err = kubeClient.GetPodAPILiveQuery(ctx, podNamespace, podName)
562564
if err != nil {
563565
return nil, cmdErr(k8sArgs, "error waiting for pod: %v", err)
564566
}

0 commit comments

Comments
 (0)