Skip to content

Commit fc72ddb

Browse files
authored
Merge pull request #1332 from dougbtv/getlivepod
always attempt a live pod get on miss to confirm its really not there
2 parents 5338017 + fb03b0f commit fc72ddb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/k8sclient/k8sclient.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func (c *ClientInfo) GetPodContext(ctx context.Context, namespace, name string)
9191
return c.Client.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
9292
}
9393

94+
// 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{})
97+
}
98+
9499
// DeletePod deletes a pod from kubernetes
95100
func (c *ClientInfo) DeletePod(namespace, name string) error {
96101
return c.Client.CoreV1().Pods(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})

pkg/multus/multus.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,7 @@ 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-
ctx, cancel := context.WithTimeout(context.TODO(), pollDuration)
562-
defer cancel()
563-
pod, err = kubeClient.GetPodContext(ctx, podNamespace, podName)
561+
pod, err = kubeClient.GetPodAPILiveQuery(podNamespace, podName)
564562
if err != nil {
565563
return nil, cmdErr(k8sArgs, "error waiting for pod: %v", err)
566564
}

0 commit comments

Comments
 (0)