Commit 3cd32ba6 authored by Seth Hoenig's avatar Seth Hoenig
Browse files

wip hybrid mode (no work)

parent a427e9ce
Branches unavailable
No related merge requests found
Showing with 28 additions and 6 deletions
+28 -6
......@@ -13,12 +13,28 @@ import (
lcc "github.com/opencontainers/runc/libcontainer/configs"
)
// In CI testing there are not yet runners available with v2 as the default, but
// we can take advantage of hybrid mode and pretend like the system is in v2 mode
// by setting NOMAD_CGROUP_V2_ROOT.
//
// The downside is we can no longer refer to IsCgroup2UnifiedMode anywhere in Nomad
// code, and docker / other drivers will also need to be reconfigured.
func init() {
if override := os.Getenv("NOMAD_CGROUP_V2_ROOT"); override != "" {
CgroupRoot = override
UseV2 = true
} else {
UseV2 = cgroups.IsCgroup2UnifiedMode()
}
fmt.Println("INIT, root:", CgroupRoot, "v2:", UseV2)
}
// UseV2 indicates whether only cgroups.v2 is enabled. If cgroups.v2 is not
// enabled or is running in hybrid mode with cgroups.v1, Nomad will make use of
// cgroups.v1
//
// This is a read-only value.
var UseV2 = cgroups.IsCgroup2UnifiedMode()
var UseV2 bool
// GetCgroupParent returns the mount point under the root cgroup in which Nomad
// will create cgroups. If parent is not set, an appropriate name for the version
......
......@@ -11,11 +11,13 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
)
const (
// CgroupRoot is hard-coded in the cgroups specification.
// It only applies to linux but helpers have references to it in driver(s).
CgroupRoot = "/sys/fs/cgroup"
)
// CgroupRoot is encoded in the cgroups specification.
//
// It only applies to Linux but there may be references to it in drivers.
//
// This value is read only, but may be modified by setting NOMAD_CGROUP_V2_ROOT
// for testing purposes (i.e. undocumented feature).
var CgroupRoot = "/sys/fs/cgroup"
// CpusetManager is used to setup cpuset cgroups for each task.
type CpusetManager interface {
......
......@@ -4,6 +4,7 @@ package cgutil
import (
"context"
"fmt"
"os"
"path/filepath"
"strings"
......@@ -280,12 +281,15 @@ func (c *cpusetManagerV2) write(id identity, set cpuset.CPUSet) {
// ensureParentCgroup will create parent cgroup for the manager if it does not
// exist yet. No PIDs are added to any cgroup yet.
func (c *cpusetManagerV2) ensureParent() error {
fmt.Println("p parentAbs:", c.parentAbs)
mgr, err := fs2.NewManager(nil, c.parentAbs, rootless)
if err != nil {
fmt.Println("A err:", err)
return err
}
if err = mgr.Apply(CreationPID); err != nil {
fmt.Println("B err:", err)
return err
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment