From 7228bab79bded0363ad8d55c11fc831f934921f4 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 14 Jan 2019 20:32:55 +0000 Subject: [PATCH] container: update: Allow updates once container is created 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 --- cli/update.go | 4 ++-- virtcontainers/container.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/update.go b/cli/update.go index 4a25fbe9c..edbe5262b 100644 --- a/cli/update.go +++ b/cli/update.go @@ -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{ diff --git a/virtcontainers/container.go b/virtcontainers/container.go index 545700b77..35366ef98 100644 --- a/virtcontainers/container.go +++ b/virtcontainers/container.go @@ -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 {