From 79dc92ad5c07b548bd53297b17fa13f86e7fd24c Mon Sep 17 00:00:00 2001 From: dougbtv Date: Thu, 19 Dec 2024 11:27:17 -0500 Subject: [PATCH] uses getlive pod for failure case, which skips delete as it is --- pkg/k8sclient/k8sclient.go | 4 ++++ pkg/multus/multus.go | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/k8sclient/k8sclient.go b/pkg/k8sclient/k8sclient.go index a96113538..57f682f3e 100644 --- a/pkg/k8sclient/k8sclient.go +++ b/pkg/k8sclient/k8sclient.go @@ -91,6 +91,10 @@ func (c *ClientInfo) GetPodContext(ctx context.Context, namespace, name string) return c.Client.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{}) } +func (c *ClientInfo) GetPodLive(namespace, name string) (*v1.Pod, error) { + return c.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{}) +} + // DeletePod deletes a pod from kubernetes func (c *ClientInfo) DeletePod(namespace, name string) error { return c.Client.CoreV1().Pods(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{}) diff --git a/pkg/multus/multus.go b/pkg/multus/multus.go index 532ec1193..8d4f0e90d 100644 --- a/pkg/multus/multus.go +++ b/pkg/multus/multus.go @@ -558,9 +558,7 @@ func GetPod(kubeClient *k8s.ClientInfo, k8sArgs *types.K8sArgs, isDel bool) (*v1 // Try one more time to get the pod directly from the apiserver; // TODO: figure out why static pods don't show up via the informer // and always hit this case. - ctx, cancel := context.WithTimeout(context.TODO(), pollDuration) - defer cancel() - pod, err = kubeClient.GetPodContext(ctx, podNamespace, podName) + pod, err = kubeClient.GetPodLive(podNamespace, podName) if err != nil { return nil, cmdErr(k8sArgs, "error waiting for pod: %v", err) }