Do not lock all containers during pod kill

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #600
Approved by: rhatdan
This commit is contained in:
Matthew Heon 2018-04-09 11:15:05 -04:00 committed by Atomic Bot
parent 8b67fbb3f2
commit 49f9397217
1 changed files with 10 additions and 10 deletions

View File

@ -298,26 +298,26 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
return nil, err
}
// We need to lock all the containers
for _, ctr := range allCtrs {
ctr.lock.Lock()
defer ctr.lock.Unlock()
if err := ctr.syncContainer(); err != nil {
return nil, err
}
}
ctrErrors := make(map[string]error)
// Send a signal to all containers
for _, ctr := range allCtrs {
ctr.lock.Lock()
if err := ctr.syncContainer(); err != nil {
ctr.lock.Unlock()
ctrErrors[ctr.ID()] = err
continue
}
// Ignore containers that are not running
if ctr.state.State != ContainerStateRunning {
ctr.lock.Unlock()
continue
}
if err := ctr.runtime.ociRuntime.killContainer(ctr, signal); err != nil {
ctr.lock.Unlock()
ctrErrors[ctr.ID()] = err
continue
}