Merge pull request #43166 from thaJeztah/20.10_backport_fix_update_sync

[20.10 backport] Fix for lack of syncronization in daemon/update.go
This commit is contained in:
Brian Goff 2022-02-17 11:08:56 -08:00 committed by GitHub
commit 7f44d606f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -42,20 +42,25 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
restoreConfig := false
backupHostConfig := *ctr.HostConfig
defer func() {
if restoreConfig {
ctr.Lock()
ctr.HostConfig = &backupHostConfig
ctr.CheckpointTo(daemon.containersReplica)
if !ctr.RemovalInProgress && !ctr.Dead {
ctr.HostConfig = &backupHostConfig
ctr.CheckpointTo(daemon.containersReplica)
}
ctr.Unlock()
}
}()
ctr.Lock()
if ctr.RemovalInProgress || ctr.Dead {
ctr.Unlock()
return errCannotUpdate(ctr.ID, fmt.Errorf("container is marked for removal and cannot be \"update\""))
}
ctr.Lock()
if err := ctr.UpdateContainer(hostConfig); err != nil {
restoreConfig = true
ctr.Unlock()
@ -66,6 +71,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
ctr.Unlock()
return errCannotUpdate(ctr.ID, err)
}
ctr.Unlock()
// if Restart Policy changed, we need to update container monitor