Create containerd task.

This commit is contained in:
Shishir Mahajan 2020-05-11 16:40:22 -07:00
parent 175e692254
commit a8bab44acf
No known key found for this signature in database
GPG Key ID: D41782E7688DEC4A
2 changed files with 12 additions and 0 deletions

View File

@ -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))
}

View File

@ -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,