Skip to content

Commit b7b6b32

Browse files
committed
Add check for CNI plugins before tearing down pod network
Signed-off-by: Sameer <[email protected]>
1 parent db97449 commit b7b6b32

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/cri/server/sandbox_stop.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ func (c *criService) stopPodSandbox(ctx context.Context, sandbox sandboxstore.Sa
111111
} else if closed {
112112
sandbox.NetNSPath = ""
113113
}
114-
if err := c.teardownPodNetwork(ctx, sandbox); err != nil {
115-
return fmt.Errorf("failed to destroy network for sandbox %q: %w", id, err)
114+
if sandbox.CNIResult != nil {
115+
if err := c.teardownPodNetwork(ctx, sandbox); err != nil {
116+
return fmt.Errorf("failed to destroy network for sandbox %q: %w", id, err)
117+
}
116118
}
117119
if err := sandbox.NetNS.Remove(); err != nil {
118120
return fmt.Errorf("failed to remove network namespace for sandbox %q: %w", id, err)

0 commit comments

Comments
 (0)