Fix cleanup context of teardownPodNetwork
Similar to other deferred cleanup operations, teardownPodNetwork should use a different context as the original context may have expired, otherwise CNI wouldn't been invoked, leading to leak of network resources, e.g. IP addresses. Signed-off-by: Quan Tian <qtian@vmware.com>
This commit is contained in:
parent
e2f784269d
commit
728743eb28
@ -132,8 +132,10 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
sandbox.NetNSPath = sandbox.NetNS.GetPath()
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
deferCtx, deferCancel := ctrdutil.DeferContext()
|
||||
defer deferCancel()
|
||||
// Teardown network if an error is returned.
|
||||
if err := c.teardownPodNetwork(ctx, sandbox); err != nil {
|
||||
if err := c.teardownPodNetwork(deferCtx, sandbox); err != nil {
|
||||
log.G(ctx).WithError(err).Errorf("Failed to destroy network for sandbox %q", id)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user