From a8bab44acf760c3cdeeac39bb589542ee9aba173 Mon Sep 17 00:00:00 2001 From: Shishir Mahajan Date: Mon, 11 May 2020 16:40:22 -0700 Subject: [PATCH] Create containerd task. --- containerd/containerd.go | 5 +++++ containerd/driver.go | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/containerd/containerd.go b/containerd/containerd.go index 7e99abe..5a10af1 100644 --- a/containerd/containerd.go +++ b/containerd/containerd.go @@ -2,6 +2,7 @@ package containerd import ( "github.com/containerd/containerd" + "github.com/containerd/containerd/cio" "github.com/containerd/containerd/oci" ) @@ -25,3 +26,7 @@ func (d *Driver) createContainer(image containerd.Image, containerName, containe containerd.WithNewSpec(oci.WithImageConfig(image)), ) } + +func (d *Driver) createTask(container containerd.Container) (containerd.Task, error) { + return container.NewTask(d.ctxContainerd, cio.NewCreator(cio.WithStdio)) +} diff --git a/containerd/driver.go b/containerd/driver.go index 216f26c..b68e35e 100644 --- a/containerd/driver.go +++ b/containerd/driver.go @@ -299,6 +299,13 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive d.logger.Info("Successfully created container with name: %s, ID: %s and snapshot with ID: %s", containerName, container.ID(), containerSnapshotName) + task, err := d.createTask(container) + if err != nil { + return nil, nil, fmt.Errorf("Error in creating task: %v", err) + } + + d.logger.Info("Task with %s ID created successfully.", task.ID()) + h := &taskHandle{ containerName: containerName, taskConfig: cfg,