Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't support cgroupns on cgroups v1 #4308

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion executor/oci/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
return nil, nil, err
}

if cgroupNamespaceSupported() {
if cgroupV2NamespaceSupported() {
s.Linux.Namespaces = append(s.Linux.Namespaces, specs.LinuxNamespace{
Type: specs.CgroupNamespace,
})
Expand Down
2 changes: 1 addition & 1 deletion executor/oci/spec_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ func getTracingSocket() string {
return ""
}

func cgroupNamespaceSupported() bool {
func cgroupV2NamespaceSupported() bool {
return false
}
14 changes: 11 additions & 3 deletions executor/oci/spec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,19 @@ func getTracingSocket() string {
return fmt.Sprintf("unix://%s", tracingSocketPath)
}

func cgroupNamespaceSupported() bool {
func cgroupV2NamespaceSupported() bool {
// Check if cgroups v2 namespaces are supported. Trying to do cgroup
// namespaces with cgroups v1 results in EINVAL when we encounter a
// non-standard hierarchy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a link to the issue ticket

// See https://github.com/moby/buildkit/issues/4108
cgroupNSOnce.Do(func() {
if _, err := os.Stat("/proc/self/ns/cgroup"); !os.IsNotExist(err) {
supportsCgroupNS = true
if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) {
return
}
if _, err := os.Stat("/sys/fs/cgroup/cgroup.subtree_control"); os.IsNotExist(err) {
return
}
supportsCgroupNS = true
})
return supportsCgroupNS
}
2 changes: 1 addition & 1 deletion executor/oci/spec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ func getTracingSocket() string {
return fmt.Sprintf("npipe://%s", filepath.ToSlash(tracingSocketPath))
}

func cgroupNamespaceSupported() bool {
func cgroupV2NamespaceSupported() bool {
return false
}
Loading