51384dd63f
This PR refactors the code path in Client startup for setting up the cpuset cgroup manager (non-linux systems not affected). Before, there was a logic bug where we would try to read the cpuset.cpus.effective cgroup interface file before ensuring nomad's parent cgroup existed. Therefor that file would not exist, and the list of useable cpus would be empty. Tasks started thereafter would not have a value set for their cpuset.cpus. The refactoring fixes some less than ideal coding style. Instead we now bootstrap each cpuset manager type (v1/v2) within its own constructor. If something goes awry during bootstrap (e.g. cgroups not enabled), the constructor returns the noop implementation and logs a warning. Fixes #14229
43 lines
1 KiB
Go
43 lines
1 KiB
Go
//go:build !linux
|
|
|
|
package cgutil
|
|
|
|
import (
|
|
"github.com/hashicorp/go-hclog"
|
|
)
|
|
|
|
const (
|
|
// DefaultCgroupParent does not apply to non-Linux operating systems.
|
|
DefaultCgroupParent = ""
|
|
)
|
|
|
|
// UseV2 is always false on non-Linux systems.
|
|
//
|
|
// This is a read-only value.
|
|
var UseV2 = false
|
|
|
|
// CreateCPUSetManager creates a no-op CpusetManager for non-Linux operating systems.
|
|
func CreateCPUSetManager(string, []uint16, hclog.Logger) CpusetManager {
|
|
return new(NoopCpusetManager)
|
|
}
|
|
|
|
// FindCgroupMountpointDir returns nothing for non-Linux operating systems.
|
|
func FindCgroupMountpointDir() (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
// GetCgroupParent returns nothing for non-Linux operating systems.
|
|
func GetCgroupParent(string) string {
|
|
return DefaultCgroupParent
|
|
}
|
|
|
|
// GetCPUsFromCgroup returns nothing for non-Linux operating systems.
|
|
func GetCPUsFromCgroup(string) ([]uint16, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// CgroupScope returns nothing for non-Linux operating systems.
|
|
func CgroupScope(allocID, task string) string {
|
|
return ""
|
|
}
|