Rename OCIRuntime to Runtime; allow gpu conflicts is they are the same runtime; add conflict test
This commit is contained in:
parent
d4f26d1eee
commit
769a3cd8b3
|
@ -341,7 +341,7 @@ var (
|
|||
})),
|
||||
"network_aliases": hclspec.NewAttr("network_aliases", "list(string)", false),
|
||||
"network_mode": hclspec.NewAttr("network_mode", "string", false),
|
||||
"oci_runtime": hclspec.NewAttr("oci_runtime", "string", false),
|
||||
"runtime": hclspec.NewAttr("runtime", "string", false),
|
||||
"pids_limit": hclspec.NewAttr("pids_limit", "number", false),
|
||||
"pid_mode": hclspec.NewAttr("pid_mode", "string", false),
|
||||
"port_map": hclspec.NewAttr("port_map", "list(map(number))", false),
|
||||
|
@ -405,7 +405,7 @@ type TaskConfig struct {
|
|||
Mounts []DockerMount `codec:"mounts"`
|
||||
NetworkAliases []string `codec:"network_aliases"`
|
||||
NetworkMode string `codec:"network_mode"`
|
||||
OCIRuntime string `codec:"oci_runtime"`
|
||||
Runtime string `codec:"runtime"`
|
||||
PidsLimit int64 `codec:"pids_limit"`
|
||||
PidMode string `codec:"pid_mode"`
|
||||
PortMap hclutils.MapStrInt `codec:"port_map"`
|
||||
|
|
|
@ -760,11 +760,11 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
|
|||
}
|
||||
hostConfig.Runtime = d.config.GPURuntimeName
|
||||
}
|
||||
if driverConfig.OCIRuntime != "" {
|
||||
if driverConfig.Runtime != "" && driverConfig.Runtime != hostConfig.Runtime {
|
||||
if hostConfig.Runtime != "" {
|
||||
return c, fmt.Errorf("oci_runtime '%s' requested conflicts with gpu runtime '%s'", driverConfig.OCIRuntime, hostConfig.Runtime)
|
||||
return c, fmt.Errorf("runtime '%s' requested conflicts with gpu runtime '%s'", driverConfig.Runtime, hostConfig.Runtime)
|
||||
}
|
||||
hostConfig.Runtime = driverConfig.OCIRuntime
|
||||
hostConfig.Runtime = driverConfig.Runtime
|
||||
}
|
||||
|
||||
// Calculate CPU Quota
|
||||
|
|
|
@ -1029,7 +1029,7 @@ func TestDockerDriver_SecurityOptFromFile(t *testing.T) {
|
|||
require.Contains(t, container.HostConfig.SecurityOpt[0], "reboot")
|
||||
}
|
||||
|
||||
func TestDockerDriver_OCIRuntime(t *testing.T) {
|
||||
func TestDockerDriver_Runtime(t *testing.T) {
|
||||
if !tu.IsCI() {
|
||||
t.Parallel()
|
||||
}
|
||||
|
@ -1037,7 +1037,7 @@ func TestDockerDriver_OCIRuntime(t *testing.T) {
|
|||
|
||||
task, cfg, ports := dockerTask(t)
|
||||
defer freeport.Return(ports)
|
||||
cfg.OCIRuntime = "runc"
|
||||
cfg.Runtime = "runc"
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
|
@ -1049,7 +1049,7 @@ func TestDockerDriver_OCIRuntime(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
require.Exactly(t, cfg.OCIRuntime, container.HostConfig.Runtime)
|
||||
require.Exactly(t, cfg.Runtime, container.HostConfig.Runtime)
|
||||
}
|
||||
|
||||
func TestDockerDriver_CreateContainerConfig(t *testing.T) {
|
||||
|
@ -1076,6 +1076,29 @@ func TestDockerDriver_CreateContainerConfig(t *testing.T) {
|
|||
require.Equal(t, containerName, c.Name)
|
||||
}
|
||||
|
||||
func TestDockerDriver_CreateContainerConfig_RuntimeConflict(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
task, cfg, ports := dockerTask(t)
|
||||
defer freeport.Return(ports)
|
||||
task.DeviceEnv[nvidia.NvidiaVisibleDevices] = "GPU_UUID_1"
|
||||
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
dh := dockerDriverHarness(t, nil)
|
||||
driver := dh.Impl().(*Driver)
|
||||
driver.gpuRuntime = true
|
||||
|
||||
// Should error if a runtime was explicitly set that doesn't match gpu runtime
|
||||
cfg.Runtime = "nvidia"
|
||||
_, err := driver.createContainerConfig(task, cfg, "org/repo:0.1")
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg.Runtime = "custom"
|
||||
_, err = driver.createContainerConfig(task, cfg, "org/repo:0.1")
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestDockerDriver_CreateContainerConfig_User(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
@ -406,13 +406,13 @@ The `docker` driver supports the following configuration in the job spec. Only
|
|||
- `readonly_rootfs` - (Optional) `true` or `false` (default). Mount
|
||||
the container's filesystem as read only.
|
||||
|
||||
- `oci_runtime` - (Optional) A string representing a configured OCI runtime to pass to docker.
|
||||
This is equivilent to the --runtime argument in the docker CLI.
|
||||
- `runtime` - (Optional) A string representing a configured runtime to pass to docker.
|
||||
This is equivilent to the --runtime argument in the docker CLI
|
||||
For example, to use gvisor:
|
||||
|
||||
```hcl
|
||||
config {
|
||||
oci_runtime = "runsc"
|
||||
runtime = "runsc"
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue