Skip to content

Commit

Permalink
Rename cgroupNamespaceSupported, add details
Browse files Browse the repository at this point in the history
This responds to review feedback from
#4308 (review)

Signed-off-by: Mark Yen <mark.yen@suse.com>
(cherry picked from commit f9ccb09)
Signed-off-by: Justin Chadwell <me@jedevc.com>
  • Loading branch information
mook-as authored and jedevc committed Oct 13, 2023
1 parent 5f72472 commit 3a2904a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion executor/oci/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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
6 changes: 5 additions & 1 deletion executor/oci/spec_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ 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.
// See https://github.com/moby/buildkit/issues/4108
cgroupNSOnce.Do(func() {
if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) {
return
Expand Down
2 changes: 1 addition & 1 deletion executor/oci/spec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ func getTracingSocket() string {
return fmt.Sprintf("npipe://%s", filepath.ToSlash(tracingSocketPath))
}

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

0 comments on commit 3a2904a

Please sign in to comment.