Make containerd runtime configurable.
This commit is contained in:
parent
74716f2f71
commit
2e3aad4ca3
@ -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)),
|
||||
)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -3,5 +3,6 @@ log_level = "INFO"
|
||||
plugin "containerd-driver" {
|
||||
config {
|
||||
enabled = true
|
||||
containerd_runtime = "io.containerd.runtime.v1.linux"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user