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

Commit

Permalink
containerd-shim-kata-v2: add the service Update support
Browse files Browse the repository at this point in the history
Add the Update api support to update a running
process's resouce.

Signed-off-by: fupan <[email protected]>
  • Loading branch information
lifupan committed Nov 28, 2018
1 parent 642231b commit 47326f5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package containerdshim

import (
"context"
"encoding/json"
"os"
sysexec "os/exec"
"path/filepath"
Expand All @@ -24,6 +25,7 @@ import (
"github.com/kata-containers/runtime/pkg/katautils"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
"github.com/opencontainers/runtime-spec/specs-go"

"github.com/containerd/containerd/api/types/task"
ptypes "github.com/gogo/protobuf/types"
Expand Down Expand Up @@ -574,7 +576,20 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.

// Update a running container
func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (*ptypes.Empty, error) {
return nil, errdefs.ErrNotImplemented
s.Lock()
defer s.Unlock()

var resources specs.LinuxResources
if err := json.Unmarshal(r.Resources.Value, &resources); err != nil {
return empty, err
}

err := s.sandbox.UpdateContainer(r.ID, resources)
if err != nil {
return nil, errdefs.ToGRPC(err)
}

return empty, nil
}

// Wait for a process to exit
Expand Down

0 comments on commit 47326f5

Please sign in to comment.