Merge pull request #1207 from Random-Liu/move-cancel
Move context cancel into defer.
This commit is contained in:
commit
994cea830b
@ -135,18 +135,16 @@ func (c *criService) stopContainer(ctx context.Context, container containerstore
|
||||
}
|
||||
|
||||
sigTermCtx, sigTermCtxCancel := context.WithTimeout(ctx, timeout)
|
||||
defer sigTermCtxCancel()
|
||||
err = c.waitContainerStop(sigTermCtx, container)
|
||||
if err == nil {
|
||||
// Container stopped on first signal no need for SIGKILL
|
||||
sigTermCtxCancel()
|
||||
return nil
|
||||
}
|
||||
// If the parent context was cancelled or exceeded return immediately
|
||||
if ctx.Err() != nil {
|
||||
sigTermCtxCancel()
|
||||
return ctx.Err()
|
||||
}
|
||||
sigTermCtxCancel()
|
||||
// sigTermCtx was exceeded. Send SIGKILL
|
||||
logrus.Debugf("Stop container %q with signal %v timed out", id, sig)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user