From b7b6b324b8b205abddebd680a86c7e6399390017 Mon Sep 17 00:00:00 2001 From: Sameer Date: Thu, 26 Sep 2024 16:06:27 -0400 Subject: [PATCH] Add check for CNI plugins before tearing down pod network Signed-off-by: Sameer --- internal/cri/server/sandbox_stop.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/cri/server/sandbox_stop.go b/internal/cri/server/sandbox_stop.go index a5b790eba..95f5780a0 100644 --- a/internal/cri/server/sandbox_stop.go +++ b/internal/cri/server/sandbox_stop.go @@ -111,8 +111,10 @@ func (c *criService) stopPodSandbox(ctx context.Context, sandbox sandboxstore.Sa } else if closed { sandbox.NetNSPath = "" } - if err := c.teardownPodNetwork(ctx, sandbox); err != nil { - return fmt.Errorf("failed to destroy network for sandbox %q: %w", id, err) + if sandbox.CNIResult != nil { + if err := c.teardownPodNetwork(ctx, sandbox); err != nil { + return fmt.Errorf("failed to destroy network for sandbox %q: %w", id, err) + } } if err := sandbox.NetNS.Remove(); err != nil { return fmt.Errorf("failed to remove network namespace for sandbox %q: %w", id, err)