Merge pull request #10744 from sameersaeed/sandbox-cni-plugins

Add check for CNI plugins before tearing down pod network
This commit is contained in:
Maksym Pavlenko 2024-09-30 15:23:58 +00:00 committed by GitHub
commit 03db11c3f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)