mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #15668 from giuseppe/skip-sys-fs-cgroup-systemd-if-missing
podman: skip /sys/fs/cgroup/systemd if not present
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
package libpod
|
package libpod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -266,9 +267,15 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
|
|||||||
g.AddMount(systemdMnt)
|
g.AddMount(systemdMnt)
|
||||||
} else {
|
} else {
|
||||||
mountOptions := []string{"bind", "rprivate"}
|
mountOptions := []string{"bind", "rprivate"}
|
||||||
|
skipMount := false
|
||||||
|
|
||||||
var statfs unix.Statfs_t
|
var statfs unix.Statfs_t
|
||||||
if err := unix.Statfs("/sys/fs/cgroup/systemd", &statfs); err != nil {
|
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")
|
mountOptions = append(mountOptions, "nodev", "noexec", "nosuid")
|
||||||
} else {
|
} else {
|
||||||
if statfs.Flags&unix.MS_NODEV == unix.MS_NODEV {
|
if statfs.Flags&unix.MS_NODEV == unix.MS_NODEV {
|
||||||
@ -284,7 +291,7 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
|
|||||||
mountOptions = append(mountOptions, "ro")
|
mountOptions = append(mountOptions, "ro")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !skipMount {
|
||||||
systemdMnt := spec.Mount{
|
systemdMnt := spec.Mount{
|
||||||
Destination: "/sys/fs/cgroup/systemd",
|
Destination: "/sys/fs/cgroup/systemd",
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
@ -294,6 +301,7 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
|
|||||||
g.AddMount(systemdMnt)
|
g.AddMount(systemdMnt)
|
||||||
g.AddLinuxMaskedPaths("/sys/fs/cgroup/systemd/release_agent")
|
g.AddLinuxMaskedPaths("/sys/fs/cgroup/systemd/release_agent")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user