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