Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
container: update: Allow updates once container is created
Browse files Browse the repository at this point in the history
Before, we would only allow for a container-update command
to proceed if the container was in the running state. So
long as the container is created, this should be allowed.

This was found using the `static` policy for Kubernetes CPU
manager[1]. Where the `update` command is called after the
`create` runtime command (when the container state is `ready`).

[1] https://github.com/kubernetes/community/blob/95a4a1/contributors/design-proposals/node/cpu-manager.md#example-scenarios-and-interactions

Fixes: #1083

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
  • Loading branch information
jcvenegas committed Jan 16, 2019
1 parent 4fda493 commit 7228bab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cli/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ other options are ignored.
span.SetTag("sandbox", sandboxID)

// container MUST be running
if status.State.State != types.StateRunning {
return fmt.Errorf("Container %s is not running", containerID)
if state := status.State.State; !(state == types.StateRunning || state == types.StateReady) {
return fmt.Errorf("Container %s is not running or Ready, the state is %s", containerID, state)
}

r := specs.LinuxResources{
Expand Down
4 changes: 2 additions & 2 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,8 @@ func (c *Container) update(resources specs.LinuxResources) error {
return err
}

if c.state.State != types.StateRunning {
return fmt.Errorf("Container not running, impossible to update")
if state := c.state.State; !(state == types.StateRunning || state == types.StateReady) {
return fmt.Errorf("Container(%s) not running or ready, impossible to update", state)
}

if c.config.Resources.CPU == nil {
Expand Down

0 comments on commit 7228bab

Please sign in to comment.