From a7f919f07184be1e27c19c40f0efda10ca47d34a Mon Sep 17 00:00:00 2001 From: CuiHaozhi Date: Wed, 8 Nov 2017 20:15:05 -0500 Subject: [PATCH] allow update running/created container. Signed-off-by: CuiHaozhi --- server/container_update_resources.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/container_update_resources.go b/server/container_update_resources.go index 9eaae8be..c58f3484 100644 --- a/server/container_update_resources.go +++ b/server/container_update_resources.go @@ -1,9 +1,11 @@ package server import ( + "fmt" "time" "github.com/gogo/protobuf/proto" + "github.com/kubernetes-incubator/cri-o/oci" rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -23,6 +25,11 @@ func (s *Server) UpdateContainerResources(ctx context.Context, req *pb.UpdateCon if err != nil { return nil, err } + state := s.Runtime().ContainerStatus(c) + if !(state.Status == oci.ContainerStateRunning || state.Status == oci.ContainerStateCreated) { + return nil, fmt.Errorf("container %s is not running or created state: %s", c.ID(), state.Status) + } + resources := toOCIResources(req.GetLinux()) if err := s.Runtime().UpdateContainer(c, resources); err != nil { return nil, err