Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 57705f5

Browse files
authored
Merge pull request #872 from yanxuean/cri-1.0
[cherry-pick] support no_pivot option for runc
2 parents 90266f5 + 835cfc3 commit 57705f5

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

docs/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ The explanation and default value of each configuration item are as follows:
3838
# snapshotter is the snapshotter used by containerd.
3939
snapshotter = "overlayfs"
4040

41+
# no_pivot disables pivot-root (linux only), required when running a container in a RamDisk with runc
42+
no_pivot = false
43+
4144
# "plugins.cri.containerd.default_runtime" is the runtime to use in containerd.
4245
[plugins.cri.containerd.default_runtime]
4346
# runtime_type is the runtime type to use in containerd e.g. io.containerd.runtime.v1.linux

pkg/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type ContainerdConfig struct {
3737
DefaultRuntime Runtime `toml:"default_runtime" json:"defaultRuntime"`
3838
// UntrustedWorkloadRuntime is a runtime to run untrusted workloads on it.
3939
UntrustedWorkloadRuntime Runtime `toml:"untrusted_workload_runtime" json:"untrustedWorkloadRuntime"`
40+
// NoPivot disables pivot-root (linux only), required when running a container in a RamDisk with runc
41+
NoPivot bool `toml:"no_pivot" json:"noPivot"`
4042
}
4143

4244
// CniConfig contains toml config related to cni
@@ -132,6 +134,7 @@ func DefaultConfig() PluginConfig {
132134
Engine: "",
133135
Root: "",
134136
},
137+
NoPivot: false,
135138
},
136139
StreamServerAddress: "",
137140
StreamServerPort: "10010",

pkg/server/container_start.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ func (c *criService) startContainer(ctx context.Context,
108108
return cntr.IO, nil
109109
}
110110

111-
task, err := container.NewTask(ctx, ioCreation)
111+
var taskOpts []containerd.NewTaskOpts
112+
if c.config.NoPivot {
113+
taskOpts = append(taskOpts, containerd.WithNoPivotRoot)
114+
}
115+
task, err := container.NewTask(ctx, ioCreation, taskOpts...)
112116
if err != nil {
113117
return errors.Wrap(err, "failed to create containerd task")
114118
}

pkg/server/sandbox_run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,13 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
293293
// Create sandbox task in containerd.
294294
log.Tracef("Create sandbox container (id=%q, name=%q).",
295295
id, name)
296+
297+
var taskOpts []containerd.NewTaskOpts
298+
if c.config.NoPivot {
299+
taskOpts = append(taskOpts, containerd.WithNoPivotRoot)
300+
}
296301
// We don't need stdio for sandbox container.
297-
task, err := container.NewTask(ctx, containerdio.NullIO)
302+
task, err := container.NewTask(ctx, containerdio.NullIO, taskOpts...)
298303
if err != nil {
299304
return status, errors.Wrap(err, "failed to create containerd task")
300305
}

0 commit comments

Comments
 (0)