Implement task update

This allows tasks to have their resources updated as they are running.

Fixes #1067

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-06-26 16:38:49 -07:00
parent 1f478be14d
commit f36e0193a4
15 changed files with 749 additions and 152 deletions

View File

@@ -7,6 +7,7 @@ import (
"runtime"
"github.com/containerd/containerd/api/services/containers/v1"
tasks "github.com/containerd/containerd/api/services/tasks/v1"
"github.com/containerd/containerd/images"
protobuf "github.com/gogo/protobuf/types"
"github.com/opencontainers/image-spec/specs-go/v1"
@@ -92,3 +93,17 @@ func WithSpec(spec *specs.Spec) NewContainerOpts {
return nil
}
}
func WithResources(resources *specs.WindowsResources) UpdateTaskOpts {
return func(ctx context.Context, client *Client, r *tasks.UpdateTaskRequest) error {
data, err := json.Marshal(resources)
if err != nil {
return err
}
r.Resources = &protobuf.Any{
TypeUrl: specs.Version,
Value: data,
}
return nil
}
}