Skip to content

Commit e9c212e

Browse files
committed
feat(config): add rootfs view opt-in
Add a rootfs_view.enabled configuration knob and document it. The flag keeps rootfs view preparation disabled unless deployments explicitly opt in. Signed-off-by: sidneychang <2190206983@qq.com>
1 parent f6ddb03 commit e9c212e

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

deployment/urunc-deploy/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ syslog = false
77
[timestamps]
88
enabled = false
99

10+
[rootfs_view]
11+
enabled = false
12+
1013
[monitors.qemu]
1114
default_memory_mb = 256
1215
default_vcpus = 1

docs/configuration.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ default_vcpus = 1
3838
[extra_binaries.virtiofsd]
3939
path = "/usr/libexec/virtiofsd"
4040
options = "--sandbox none"
41+
42+
[rootfs_view]
43+
enabled = false
4144
```
4245

4346
## Configuration Sections
@@ -89,6 +92,34 @@ destination = "/tmp/urunc-timestamps.log"
8992

9093
When enabled, `urunc` will log performance timestamps to help with debugging and optimization.
9194

95+
### Rootfs View Configuration
96+
97+
The `[rootfs_view]` section controls whether the urunc shim prepares a
98+
per-container containerd rootfs view at task Create (for `devmapper` /
99+
`blockfile` snapshotters).
100+
101+
| Option | Type | Default | Description |
102+
|--------|------|---------|-------------|
103+
| `enabled` | boolean | `false` | Prepare rootfs views for container block rootfs after shim task Create |
104+
105+
When `enabled = true`, the shim first lets the wrapped task service create the
106+
task so the bundle rootfs is mounted. It then runs `ChooseRootfs` and prepares a
107+
view only if **all** of the following hold:
108+
109+
1. The container snapshotter is block-based (`devmapper` or `blockfile`).
110+
2. Shim `ChooseRootfs` selected **container block rootfs** (`type=block` with a
111+
non-empty `MountedPath`).
112+
113+
This matches the block-rootfs boot-artifact path: kernel/initrd are read from a
114+
read-only view instead of being copied out of the container rootfs before attach.
115+
116+
**Example:**
117+
118+
```toml
119+
[rootfs_view]
120+
enabled = true
121+
```
122+
92123
### Monitor Configuration
93124

94125
The `[monitors]` section allows you to configure default settings for different
@@ -201,6 +232,9 @@ To create a configuration file, you can:
201232
[monitors.spt]
202233
default_memory_mb = 256
203234
default_vcpus = 1
235+
236+
[rootfs_view]
237+
enabled = false
204238
EOF
205239
```
206240
@@ -244,6 +278,9 @@ default_vcpus = 1
244278
default_memory_mb = 256
245279
default_vcpus = 1
246280
# path is not set by default - urunc will search in PATH
281+
282+
[rootfs_view]
283+
enabled = false
247284
```
248285
249286
## Notes

pkg/unikontainers/urunc_config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ type UruncTimestamps struct {
3434
Destination string `toml:"destination"` // Used to specify a file for timestamps
3535
}
3636

37+
// UruncRootfsView configures shim-side per-container rootfs views (devmapper/blockfile).
38+
type UruncRootfsView struct {
39+
Enabled bool `toml:"enabled"`
40+
}
41+
3742
type UruncConfig struct {
3843
Log UruncLog `toml:"log"`
3944
Timestamps UruncTimestamps `toml:"timestamps"`
45+
RootfsView UruncRootfsView `toml:"rootfs_view"`
4046
Monitors map[string]types.MonitorConfig `toml:"monitors"`
4147
ExtraBins map[string]types.ExtraBinConfig `toml:"extra_binaries"`
4248
}
@@ -94,10 +100,15 @@ func defaultExtraBinConfig() map[string]types.ExtraBinConfig {
94100
}
95101
}
96102

103+
func defaultRootfsViewConfig() UruncRootfsView {
104+
return UruncRootfsView{Enabled: false}
105+
}
106+
97107
func defaultUruncConfig() *UruncConfig {
98108
return &UruncConfig{
99109
Log: defaultLogConfig(),
100110
Timestamps: defaultTimestampsConfig(),
111+
RootfsView: defaultRootfsViewConfig(),
101112
Monitors: defaultMonitorsConfig(),
102113
ExtraBins: defaultExtraBinConfig(),
103114
}

0 commit comments

Comments
 (0)