aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-07 20:39:39 +0200
committerGitHub <noreply@github.com>2022-09-07 20:39:39 +0200
commit3d482a7ef2eb6e307992cd8bbea1153827d5e085 (patch)
tree4a4709bc483854702d8beae1815d231767f6a006 /libpod
parent31af4863626f211bb8f963da6a0392273f507680 (diff)
parentf75c3181bf4c3ebc29da9eadb0a8eb78a4e3a9dd (diff)
downloadpodman-3d482a7ef2eb6e307992cd8bbea1153827d5e085.tar.gz
podman-3d482a7ef2eb6e307992cd8bbea1153827d5e085.tar.bz2
podman-3d482a7ef2eb6e307992cd8bbea1153827d5e085.zip
Merge pull request #15668 from giuseppe/skip-sys-fs-cgroup-systemd-if-missing
podman: skip /sys/fs/cgroup/systemd if not present
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 83882ecac..9b05a2d61 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -4,6 +4,7 @@
package libpod
import (
+ "errors"
"fmt"
"os"
"path"
@@ -266,9 +267,15 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
g.AddMount(systemdMnt)
} else {
mountOptions := []string{"bind", "rprivate"}
+ skipMount := false
var statfs unix.Statfs_t
if err := unix.Statfs("/sys/fs/cgroup/systemd", &statfs); err != nil {
+ if errors.Is(err, os.ErrNotExist) {
+ // If the mount is missing on the host, we cannot bind mount it so
+ // just skip it.
+ skipMount = true
+ }
mountOptions = append(mountOptions, "nodev", "noexec", "nosuid")
} else {
if statfs.Flags&unix.MS_NODEV == unix.MS_NODEV {
@@ -284,15 +291,16 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
mountOptions = append(mountOptions, "ro")
}
}
-
- systemdMnt := spec.Mount{
- Destination: "/sys/fs/cgroup/systemd",
- Type: "bind",
- Source: "/sys/fs/cgroup/systemd",
- Options: mountOptions,
+ if !skipMount {
+ systemdMnt := spec.Mount{
+ Destination: "/sys/fs/cgroup/systemd",
+ Type: "bind",
+ Source: "/sys/fs/cgroup/systemd",
+ Options: mountOptions,
+ }
+ g.AddMount(systemdMnt)
+ g.AddLinuxMaskedPaths("/sys/fs/cgroup/systemd/release_agent")
}
- g.AddMount(systemdMnt)
- g.AddLinuxMaskedPaths("/sys/fs/cgroup/systemd/release_agent")
}
return nil