Skip to content

Commit 3a2904a

Browse files
mook-asjedevc
authored andcommitted
Rename cgroupNamespaceSupported, add details
This responds to review feedback from moby#4308 (review) Signed-off-by: Mark Yen <[email protected]> (cherry picked from commit f9ccb09) Signed-off-by: Justin Chadwell <[email protected]>
1 parent 5f72472 commit 3a2904a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

executor/oci/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
137137
return nil, nil, err
138138
}
139139

140-
if cgroupNamespaceSupported() {
140+
if cgroupV2NamespaceSupported() {
141141
s.Linux.Namespaces = append(s.Linux.Namespaces, specs.LinuxNamespace{
142142
Type: specs.CgroupNamespace,
143143
})

executor/oci/spec_unix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ func getTracingSocket() string {
147147
return fmt.Sprintf("unix://%s", tracingSocketPath)
148148
}
149149

150-
func cgroupNamespaceSupported() bool {
150+
func cgroupV2NamespaceSupported() bool {
151+
// Check if cgroups v2 namespaces are supported. Trying to do cgroup
152+
// namespaces with cgroups v1 results in EINVAL when we encounter a
153+
// non-standard hierarchy.
154+
// See https://github.com/moby/buildkit/issues/4108
151155
cgroupNSOnce.Do(func() {
152156
if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) {
153157
return

executor/oci/spec_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ func getTracingSocket() string {
6464
return fmt.Sprintf("npipe://%s", filepath.ToSlash(tracingSocketPath))
6565
}
6666

67-
func cgroupNamespaceSupported() bool {
67+
func cgroupV2NamespaceSupported() bool {
6868
return false
6969
}

0 commit comments

Comments
 (0)