Skip to content

Commit d44c438

Browse files
MikeZappa87k8s-infra-cherrypick-robot
authored andcommitted
address comment
Signed-off-by: Michael Zappa <[email protected]>
1 parent f183527 commit d44c438

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

internal/cri/server/sandbox_stop.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,12 @@ func (c *criService) stopPodSandbox(ctx context.Context, sandbox sandboxstore.Sa
114114
} else if closed {
115115
sandbox.NetNSPath = ""
116116
}
117-
if sandbox.CNIResult != nil {
118-
if err := c.teardownPodNetwork(ctx, sandbox); err != nil {
117+
if err := c.teardownPodNetwork(ctx, sandbox); err != nil {
118+
if sandbox.CNIResult != nil {
119119
return fmt.Errorf("failed to destroy network for sandbox %q: %w", id, err)
120+
} else {
121+
log.G(ctx).WithError(err).Warnf("failed to destroy network for sandbox %q; and ignoring because the sandbox network setup result is nil indicating the network setup never completed", id)
120122
}
121-
} else {
122-
log.G(ctx).Warnf("CNI result is not found for sandbox %q, attempting teardown anyway, ignoring errors", id)
123-
_ = c.teardownPodNetwork(ctx, sandbox)
124123
}
125124
if err := sandbox.NetNS.Remove(); err != nil {
126125
return fmt.Errorf("failed to remove network namespace for sandbox %q: %w", id, err)

0 commit comments

Comments
 (0)