Skip to content

Commit 64f491d

Browse files
committed
main: exit if no Cgroups v2
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent ae81781 commit 64f491d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

cmd/buildah/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/containers/buildah/define"
1515
"github.com/containers/buildah/pkg/cli"
1616
"github.com/containers/buildah/pkg/parse"
17+
"github.com/opencontainers/cgroups"
1718
ispecs "github.com/opencontainers/image-spec/specs-go"
1819
rspecs "github.com/opencontainers/runtime-spec/specs-go"
1920
"github.com/sirupsen/logrus"
@@ -231,6 +232,11 @@ func main() {
231232
return
232233
}
233234

235+
cgroupsv2 := cgroups.IsCgroup2UnifiedMode()
236+
if !cgroupsv2 {
237+
logrus.Fatalf("Did not detect Cgroups v2 on your system. Please switch to Cgroups v2.")
238+
}
239+
234240
// Hard code TMPDIR functions to use $TMPDIR or /var/tmp
235241
os.Setenv("TMPDIR", parse.GetTempDir())
236242

info.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/containers/buildah/util"
1515
v1 "github.com/opencontainers/image-spec/specs-go/v1"
1616
"github.com/sirupsen/logrus"
17-
"go.podman.io/common/pkg/cgroups"
1817
"go.podman.io/storage"
1918
"go.podman.io/storage/pkg/system"
2019
"go.podman.io/storage/pkg/unshare"
@@ -51,10 +50,6 @@ func hostInfo() map[string]any {
5150
info["cpus"] = runtime.NumCPU()
5251
info["rootless"] = unshare.IsRootless()
5352

54-
_, err := cgroups.IsCgroup2UnifiedMode()
55-
if err != nil {
56-
logrus.Error(err, "err reading cgroups mode")
57-
}
5853
ociruntime := util.Runtime()
5954
info["OCIRuntime"] = ociruntime
6055

-13 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)