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
ea9accf4
Commit
ea9accf4
authored
3 years ago
by
Seth Hoenig
Browse files
Options
Download
Email Patches
Plain Diff
wip build on darwin
parent
ef5f97a4
Branches unavailable
No related merge requests found
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
client/lib/cgutil/cgutil_linux.go
+0
-12
client/lib/cgutil/cgutil_linux.go
client/lib/cgutil/cgutil_linux_test.go
+2
-0
client/lib/cgutil/cgutil_linux_test.go
client/lib/cgutil/cgutil_noop.go
+0
-1
client/lib/cgutil/cgutil_noop.go
client/lib/cgutil/cpuset_manager.go
+20
-0
client/lib/cgutil/cpuset_manager.go
client/lib/cgutil/cpuset_manager_v2.go
+0
-3
client/lib/cgutil/cpuset_manager_v2.go
drivers/docker/config_test.go
+1
-1
drivers/docker/config_test.go
drivers/docker/driver.go
+5
-5
drivers/docker/driver.go
drivers/docker/reconcile_cpuset.go
+7
-1
drivers/docker/reconcile_cpuset.go
drivers/docker/reconcile_cpuset_noop.go
+19
-0
drivers/docker/reconcile_cpuset_noop.go
drivers/docker/reconcile_cpuset_test.go
+2
-0
drivers/docker/reconcile_cpuset_test.go
with
56 additions
and
23 deletions
+56
-23
client/lib/cgutil/cgutil_linux.go
+
0
-
12
View file @
ea9accf4
...
...
@@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/helper/uuid"
...
...
@@ -47,17 +46,6 @@ func GetCPUsFromCgroup(group string) ([]uint16, error) {
return
getCPUsFromCgroupV1
(
getParentV1
(
group
))
}
// SplitPath determines the parent and cgroup from p.
// p must contain at least 2 elements (parent + cgroup).
//
// Handles the cgroup root if present.
func
SplitPath
(
p
string
)
(
string
,
string
)
{
p
=
strings
.
TrimPrefix
(
p
,
CgroupRoot
)
p
=
strings
.
Trim
(
p
,
"/"
)
parts
:=
strings
.
Split
(
p
,
string
(
os
.
PathSeparator
))
return
parts
[
0
],
"/"
+
filepath
.
Join
(
parts
[
1
:
]
...
)
}
// CgroupScope returns the name of the scope for Nomad's managed cgroups for
// the given allocID and task.
//
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cgutil_linux_test.go
+
2
-
0
View file @
ea9accf4
//go:build linux
package
cgutil
import
(
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cgutil_noop.go
+
0
-
1
View file @
ea9accf4
//go:build !linux
// +build !linux
package
cgutil
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager.go
+
20
-
0
View file @
ea9accf4
...
...
@@ -3,11 +3,20 @@ package cgutil
import
(
"context"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/hashicorp/nomad/lib/cpuset"
"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"
)
// CpusetManager is used to setup cpuset cgroups for each task.
type
CpusetManager
interface
{
// Init should be called with the initial set of reservable cores before any
...
...
@@ -62,3 +71,14 @@ func makeID(allocID, task string) string {
func
makeScope
(
id
string
)
string
{
return
id
+
".scope"
}
// SplitPath determines the parent and cgroup from p.
// p must contain at least 2 elements (parent + cgroup).
//
// Handles the cgroup root if present.
func
SplitPath
(
p
string
)
(
string
,
string
)
{
p
=
strings
.
TrimPrefix
(
p
,
CgroupRoot
)
p
=
strings
.
Trim
(
p
,
"/"
)
parts
:=
strings
.
Split
(
p
,
string
(
os
.
PathSeparator
))
return
parts
[
0
],
"/"
+
filepath
.
Join
(
parts
[
1
:
]
...
)
}
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager_v2.go
+
0
-
3
View file @
ea9accf4
...
...
@@ -20,9 +20,6 @@ import (
)
const
(
// CgroupRoot is hard-coded in the cgroups specification.
CgroupRoot
=
"/sys/fs/cgroup"
// CreationPID is a special PID in libcontainer used to denote a cgroup
// should be created, but with no process added.
CreationPID
=
-
1
...
...
This diff is collapsed.
Click to expand it.
drivers/docker/config_test.go
+
1
-
1
View file @
ea9accf4
...
...
@@ -704,7 +704,7 @@ func TestConfig_DriverConfig_PullActivityTimeout(t *testing.T) {
func
TestConfig_DriverConfig_AllowRuntimes
(
t
*
testing
.
T
)
{
ci
.
Parallel
(
t
)
cases
:=
[]
struct
{
name
string
config
string
...
...
This diff is collapsed.
Click to expand it.
drivers/docker/driver.go
+
5
-
5
View file @
ea9accf4
...
...
@@ -31,7 +31,6 @@ import (
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/drivers"
pstructs
"github.com/hashicorp/nomad/plugins/shared/structs"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/ryanuber/go-glob"
)
...
...
@@ -125,7 +124,7 @@ type Driver struct {
detectedLock
sync
.
RWMutex
danglingReconciler
*
containerReconciler
cpusetFixer
*
c
pusetFixer
cpusetFixer
C
pusetFixer
}
// NewDockerDriver returns a docker implementation of a driver plugin
...
...
@@ -1207,9 +1206,10 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
config
.
Env
=
task
.
EnvList
()
containerName
:=
fmt
.
Sprintf
(
"%s-%s"
,
strings
.
ReplaceAll
(
task
.
Name
,
"/"
,
"_"
),
task
.
AllocID
)
if
cgroups
.
IsCgroup2UnifiedMode
()
{
containerName
=
fmt
.
Sprintf
(
"%s.%s.scope"
,
task
.
AllocID
,
task
.
Name
)
}
// todo: remove
//if cgroups.IsCgroup2UnifiedMode() {
// containerName = fmt.Sprintf("%s.%s.scope", task.AllocID, task.Name)
//}
logger
.
Info
(
"setting container name"
,
"container_name"
,
containerName
)
var
networkingConfig
*
docker
.
NetworkingConfig
...
...
This diff is collapsed.
Click to expand it.
drivers/docker/reconcile_cpuset.go
+
7
-
1
View file @
ea9accf4
//go:build linux
package
docker
import
(
...
...
@@ -16,6 +18,10 @@ const (
cpusetReconcileInterval
=
1
*
time
.
Second
)
type
CpusetFixer
interface
{
Start
()
}
// cpusetFixer adjusts the cpuset.cpus cgroup value to the assigned value by Nomad.
//
// Due to Docker not allowing the configuration of the full cgroup path, we must
...
...
@@ -35,7 +41,7 @@ type cpusetFixer struct {
tasks
func
()
map
[
coordinate
]
struct
{}
}
func
newCpusetFixer
(
d
*
Driver
)
*
c
pusetFixer
{
func
newCpusetFixer
(
d
*
Driver
)
C
pusetFixer
{
return
&
cpusetFixer
{
interval
:
cpusetReconcileInterval
,
ctx
:
d
.
ctx
,
...
...
This diff is collapsed.
Click to expand it.
drivers/docker/reconcile_cpuset_noop.go
0 → 100644
+
19
-
0
View file @
ea9accf4
//go:build !linux
package
docker
type
CpusetFixer
interface
{
Start
()
}
func
newCpusetFixer
(
*
Driver
)
CpusetFixer
{
return
new
(
noop
)
}
type
noop
struct
{
// empty
}
func
(
*
noop
)
Start
()
{
// empty
}
This diff is collapsed.
Click to expand it.
drivers/docker/reconcile_cpuset_test.go
+
2
-
0
View file @
ea9accf4
//go:build linux
package
docker
import
(
...
...
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