Handle teardown failure to avoid blocking cleanup

Signed-off-by: Matteo Pulcini <Matteo.Pulcini@ibm.com>
This commit is contained in:
Matteo Pulcini 2024-10-15 15:35:20 -07:00
parent 5d49f2e3ae
commit 0742238cd6

View File

@ -220,6 +220,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
// Teardown network if an error is returned.
if cleanupErr = c.teardownPodNetwork(deferCtx, sandbox); cleanupErr != nil {
log.G(ctx).WithError(cleanupErr).Errorf("Failed to destroy network for sandbox %q", id)
// ignoring failed to destroy networks when we failed to setup networks
if sandbox.CNIResult == nil {
cleanupErr = nil
}
}
}