Skip to content

Commit 26f8767

Browse files
committed
libpod: remove cgv1 mount logic
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 8be9100 commit 26f8767

File tree

1 file changed

+2
-45
lines changed

1 file changed

+2
-45
lines changed

libpod/container_internal_linux.go

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package libpod
44

55
import (
6-
"errors"
76
"fmt"
87
"io/fs"
98
"os"
@@ -30,9 +29,7 @@ import (
3029
"golang.org/x/sys/unix"
3130
)
3231

33-
var (
34-
bindOptions = []string{define.TypeBind, "rprivate"}
35-
)
32+
var bindOptions = []string{define.TypeBind, "rprivate"}
3633

3734
func (c *Container) mountSHM(shmOptions string) error {
3835
contextType := "context"
@@ -301,47 +298,7 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro
301298
}
302299
g.AddMount(systemdMnt)
303300
} else {
304-
hasSystemdMount := MountExists(mounts, "/sys/fs/cgroup/systemd")
305-
if hasCgroupNs && !hasSystemdMount {
306-
return errors.New("cgroup namespace is not supported with cgroup v1 and systemd mode")
307-
}
308-
mountOptions := []string{define.TypeBind, "rprivate"}
309-
310-
if !hasSystemdMount {
311-
skipMount := hasSystemdMount
312-
var statfs unix.Statfs_t
313-
if err := unix.Statfs("/sys/fs/cgroup/systemd", &statfs); err != nil {
314-
if errors.Is(err, os.ErrNotExist) {
315-
// If the mount is missing on the host, we cannot bind mount it so
316-
// just skip it.
317-
skipMount = true
318-
}
319-
mountOptions = append(mountOptions, "nodev", "noexec", "nosuid")
320-
} else {
321-
if statfs.Flags&unix.MS_NODEV == unix.MS_NODEV {
322-
mountOptions = append(mountOptions, "nodev")
323-
}
324-
if statfs.Flags&unix.MS_NOEXEC == unix.MS_NOEXEC {
325-
mountOptions = append(mountOptions, "noexec")
326-
}
327-
if statfs.Flags&unix.MS_NOSUID == unix.MS_NOSUID {
328-
mountOptions = append(mountOptions, "nosuid")
329-
}
330-
if statfs.Flags&unix.MS_RDONLY == unix.MS_RDONLY {
331-
mountOptions = append(mountOptions, "ro")
332-
}
333-
}
334-
if !skipMount {
335-
systemdMnt := spec.Mount{
336-
Destination: "/sys/fs/cgroup/systemd",
337-
Type: define.TypeBind,
338-
Source: "/sys/fs/cgroup/systemd",
339-
Options: mountOptions,
340-
}
341-
g.AddMount(systemdMnt)
342-
g.AddLinuxMaskedPaths("/sys/fs/cgroup/systemd/release_agent")
343-
}
344-
}
301+
return fmt.Errorf("cgroups v1 not supported.")
345302
}
346303

347304
return nil

0 commit comments

Comments
 (0)