diff --git a/containerd/containerd.go b/containerd/containerd.go index 5a10af1..75d781a 100644 --- a/containerd/containerd.go +++ b/containerd/containerd.go @@ -18,10 +18,11 @@ func (d *Driver) pullImage(imageName string) (containerd.Image, error) { return d.client.Pull(d.ctxContainerd, imageName, containerd.WithPullUnpack) } -func (d *Driver) createContainer(image containerd.Image, containerName, containerSnapshotName string) (containerd.Container, error) { +func (d *Driver) createContainer(image containerd.Image, containerName, containerSnapshotName, containerdRuntime string) (containerd.Container, error) { return d.client.NewContainer( d.ctxContainerd, containerName, + containerd.WithRuntime(containerdRuntime, nil), containerd.WithNewSnapshot(containerSnapshotName, image), containerd.WithNewSpec(oci.WithImageConfig(image)), ) diff --git a/containerd/driver.go b/containerd/driver.go index b70a7bf..87939ef 100644 --- a/containerd/driver.go +++ b/containerd/driver.go @@ -59,6 +59,7 @@ var ( hclspec.NewAttr("enabled", "bool", false), hclspec.NewLiteral("true"), ), + "containerd_runtime": hclspec.NewAttr("containerd_runtime", "string", true), }) // taskConfigSpec is the specification of the plugin's configuration for @@ -81,7 +82,8 @@ var ( // Config contains configuration information for the plugin type Config struct { - Enabled bool `codec:"enabled"` + Enabled bool `codec:"enabled"` + ContainerdRuntime string `codec:"containerd_runtime"` } // TaskConfig contains configuration information for a task that runs with @@ -289,9 +291,10 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive } d.logger.Info("Successfully pulled %s image\n", image.Name()) + d.logger.Info("Containerd runtime: %s\n", d.config.ContainerdRuntime) containerSnapshotName := fmt.Sprintf("%s-snapshot", containerName) - container, err := d.createContainer(image, containerName, containerSnapshotName) + container, err := d.createContainer(image, containerName, containerSnapshotName, d.config.ContainerdRuntime) if err != nil { return nil, nil, fmt.Errorf("Error in creating container: %v", err) } diff --git a/example/agent.hcl b/example/agent.hcl index 9f4a1e2..ce86e6c 100644 --- a/example/agent.hcl +++ b/example/agent.hcl @@ -3,5 +3,6 @@ log_level = "INFO" plugin "containerd-driver" { config { enabled = true + containerd_runtime = "io.containerd.runtime.v1.linux" } }