Files
nomad/client/lib/cgroupslib/mount.go
Seth Hoenig a4cc76bd3e numa: enable numa topology detection (#18146)
* client: refactor cgroups management in client

* client: fingerprint numa topology

* client: plumb numa and cgroups changes to drivers

* client: cleanup task resource accounting

* client: numa client and config plumbing

* lib: add a stack implementation

* tools: remove ec2info tool

* plugins: fixup testing for cgroups / numa changes

* build: update makefile and package tests and cl
2023-08-10 17:05:30 -05:00

43 lines
646 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build linux
package cgroupslib
import (
"bufio"
"io"
"os"
"strings"
"github.com/hashicorp/go-set"
)
func detect() Mode {
f, err := os.Open("/proc/self/mountinfo")
if err != nil {
return OFF
}
defer func() {
_ = f.Close()
}()
return scan(f)
}
func scan(in io.Reader) Mode {
scanner := bufio.NewScanner(in)
for scanner.Scan() {
tokens := set.From(strings.Fields(scanner.Text()))
if tokens.Contains("/sys/fs/cgroup") {
if tokens.Contains("tmpfs") {
return CG1
}
if tokens.Contains("cgroup2") {
return CG2
}
}
}
return OFF
}