cgroups: reuse version check from c/common
[NO NEW TESTS NEEDED] Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
bbea3eb544
commit
951dccd3ff
3
info.go
3
info.go
|
@ -12,6 +12,7 @@ import (
|
|||
internalUtil "github.com/containers/buildah/internal/util"
|
||||
putil "github.com/containers/buildah/pkg/util"
|
||||
"github.com/containers/buildah/util"
|
||||
"github.com/containers/common/pkg/cgroups"
|
||||
"github.com/containers/storage"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
|
@ -50,7 +51,7 @@ func hostInfo() map[string]interface{} {
|
|||
info["cpus"] = runtime.NumCPU()
|
||||
info["rootless"] = unshare.IsRootless()
|
||||
|
||||
unified, err := util.IsCgroup2UnifiedMode()
|
||||
unified, err := cgroups.IsCgroup2UnifiedMode()
|
||||
if err != nil {
|
||||
logrus.Error(err, "err reading cgroups mode")
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/containers/buildah/define"
|
||||
|
@ -376,12 +375,6 @@ func TruncateString(str string, to int) string {
|
|||
return newStr
|
||||
}
|
||||
|
||||
var (
|
||||
isUnifiedOnce sync.Once
|
||||
isUnified bool
|
||||
isUnifiedErr error
|
||||
)
|
||||
|
||||
// fileExistsAndNotADir - Check to see if a file exists
|
||||
// and that it is not a directory.
|
||||
func fileExistsAndNotADir(path string) (bool, error) {
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
|
||||
func IsCgroup2UnifiedMode() (bool, error) {
|
||||
isUnifiedOnce.Do(func() {
|
||||
var st syscall.Statfs_t
|
||||
if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
|
||||
isUnified, isUnifiedErr = false, err
|
||||
} else {
|
||||
isUnified, isUnifiedErr = st.Type == unix.CGROUP2_SUPER_MAGIC, nil
|
||||
}
|
||||
})
|
||||
return isUnified, isUnifiedErr
|
||||
}
|
Loading…
Reference in New Issue