Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
3cd32ba6
Commit
3cd32ba6
authored
3 years ago
by
Seth Hoenig
Browse files
Options
Download
Email Patches
Plain Diff
wip hybrid mode (no work)
parent
a427e9ce
Branches unavailable
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/lib/cgutil/cgutil_linux.go
+17
-1
client/lib/cgutil/cgutil_linux.go
client/lib/cgutil/cpuset_manager.go
+7
-5
client/lib/cgutil/cpuset_manager.go
client/lib/cgutil/cpuset_manager_v2.go
+4
-0
client/lib/cgutil/cpuset_manager_v2.go
with
28 additions
and
6 deletions
+28
-6
client/lib/cgutil/cgutil_linux.go
+
17
-
1
View file @
3cd32ba6
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager.go
+
7
-
5
View file @
3cd32ba6
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager_v2.go
+
4
-
0
View file @
3cd32ba6
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help