Skip to content

Commit

Permalink
fix: allow rootfs propagation configuration for extension services
Browse files Browse the repository at this point in the history
Fixes #7873

Some services which perform mounts inside the container which require
mounts to propagate back to the host (e.g. `stargz-snapshotter`) require
this configuration setting.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Nov 13, 2023
1 parent 57dc796 commit 06941b7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/app/machined/pkg/system/services/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (svc *Extension) DependsOn(r runtime.Runtime) []string {
func (svc *Extension) getOCIOptions(envVars []string) []oci.SpecOpts {
ociOpts := []oci.SpecOpts{
oci.WithRootFSPath(filepath.Join(constants.ExtensionServicesRootfsPath, svc.Spec.Name)),
containerd.WithRootfsPropagation(svc.Spec.Container.Security.RootfsPropagation),
oci.WithCgroup(constants.CgroupExtensions),
oci.WithMounts(svc.Spec.Container.Mounts),
oci.WithHostNamespace(specs.NetworkNamespace),
Expand Down
24 changes: 24 additions & 0 deletions internal/integration/api/extensions_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,30 @@ func (suite *ExtensionsSuiteQEMU) TestExtensionsGvisor() {
suite.Require().NoError(suite.WaitForPodToBeRunning(suite.ctx, 5*time.Minute, "default", "nginx-gvisor"))
}

// TestExtensionsStargz verifies stargz snapshotter.
func (suite *ExtensionsSuiteQEMU) TestExtensionsStargz() {
_, err := suite.Clientset.CoreV1().Pods("default").Create(suite.ctx, &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "stargz-hello",
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "stargz-hello",
Image: "ghcr.io/stargz-containers/alpine:3.15.3-esgz",
Args: []string{"sleep", "inf"},
},
},
},
}, metav1.CreateOptions{})
defer suite.Clientset.CoreV1().Pods("default").Delete(suite.ctx, "stargz-hello", metav1.DeleteOptions{}) //nolint:errcheck

suite.Require().NoError(err)

// wait for the pod to be ready
suite.Require().NoError(suite.WaitForPodToBeRunning(suite.ctx, 5*time.Minute, "default", "stargz-hello"))
}

// TestExtensionsZFS verifies zfs is working, udev rules work and the pool is mounted on reboot.
func (suite *ExtensionsSuiteQEMU) TestExtensionsZFS() {
node := suite.RandomDiscoveredNodeInternalIP(machine.TypeWorker)
Expand Down
2 changes: 2 additions & 0 deletions pkg/machinery/extensions/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type Security struct {
ReadonlyPaths []string `yaml:"readonlyPaths"`
// WriteableRootfs
WriteableRootfs bool `yaml:"writeableRootfs"`
// RootfsPropagation is the propagation mode for the rootfs mount.
RootfsPropagation string `yaml:"rootfsPropagation,omitempty"`
}

// Dependency describes a service Dependency.
Expand Down
3 changes: 3 additions & 0 deletions website/content/v1.6/advanced/extension-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ readonlyPaths:
- "/another/readonly/path"
writeableRootfs: true
writeableSysfs: true
rootfsPropagation: shared
```

> * The rootfs is readonly by default unless `writeableRootfs: true` is set.
Expand All @@ -113,6 +114,8 @@ To set empty read only paths use:
> security:
> readonlyPaths: []
> ```
>
> * Rootfs propagation is not set by default (container mounts are private).

### `depends`

Expand Down

0 comments on commit 06941b7

Please sign in to comment.