Skip to content

Commit 6a7fa68

Browse files
Plugin configuration level privileged mode.
1 parent a308178 commit 6a7fa68

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

containerd/containerd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (d *Driver) createContainer(containerConfig *ContainerConfig, config *TaskC
9595

9696
opts = append(opts, oci.WithImageConfigArgs(containerConfig.Image, args))
9797

98+
if !d.config.AllowPrivileged && config.Privileged {
99+
return nil, fmt.Errorf("Running privileged jobs are not allowed. Set allow_privileged to true in plugin config to allow running privileged jobs.")
100+
}
101+
98102
// Enable privileged mode.
99103
if config.Privileged {
100104
opts = append(opts, oci.WithPrivileged)

containerd/driver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ var (
7979
),
8080
"containerd_runtime": hclspec.NewAttr("containerd_runtime", "string", true),
8181
"stats_interval": hclspec.NewAttr("stats_interval", "string", false),
82+
"allow_privileged": hclspec.NewDefault(
83+
hclspec.NewAttr("allow_privileged", "bool", false),
84+
hclspec.NewLiteral("true"),
85+
),
8286
})
8387

8488
// taskConfigSpec is the specification of the plugin's configuration for
@@ -130,6 +134,7 @@ type Config struct {
130134
Enabled bool `codec:"enabled"`
131135
ContainerdRuntime string `codec:"containerd_runtime"`
132136
StatsInterval string `codec:"stats_interval"`
137+
AllowPrivileged bool `codec:"allow_privileged"`
133138
}
134139

135140
// Volume, bind, and tmpfs type mounts are supported.

0 commit comments

Comments
 (0)