Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20.10 backport] Fix for lack of syncronization in daemon/update.go #43166

Merged
merged 1 commit into from Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions daemon/update.go
Expand Up @@ -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()
Expand All @@ -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
Expand Down