Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
129e6857
Commit
129e6857
authored
3 years ago
by
Seth Hoenig
Browse files
Options
Download
Email Patches
Plain Diff
wip demo
parent
c4fade47
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
client/allocrunner/taskrunner/task_runner.go
+2
-0
client/allocrunner/taskrunner/task_runner.go
client/config/config.go
+1
-1
client/config/config.go
client/lib/cgutil/cgutil_linux.go
+46
-2
client/lib/cgutil/cgutil_linux.go
client/lib/cgutil/cpuset_manager.go
+6
-4
client/lib/cgutil/cpuset_manager.go
client/lib/cgutil/cpuset_manager_v2_linux.go
+174
-46
client/lib/cgutil/cpuset_manager_v2_linux.go
command/agent/agent.go
+3
-0
command/agent/agent.go
drivers/exec/driver.go
+6
-0
drivers/exec/driver.go
drivers/shared/executor/executor.go
+10
-1
drivers/shared/executor/executor.go
drivers/shared/executor/executor_linux.go
+45
-26
drivers/shared/executor/executor_linux.go
drivers/shared/executor/executor_universal_linux.go
+5
-3
drivers/shared/executor/executor_universal_linux.go
drivers/shared/executor/grpc_client.go
+3
-0
drivers/shared/executor/grpc_client.go
drivers/shared/executor/grpc_server.go
+3
-0
drivers/shared/executor/grpc_server.go
drivers/shared/executor/proto/executor.pb.go
+83
-66
drivers/shared/executor/proto/executor.pb.go
drivers/shared/executor/proto/executor.proto
+2
-0
drivers/shared/executor/proto/executor.proto
lib/cpuset/cpuset.go
+16
-0
lib/cpuset/cpuset.go
plugins/drivers/driver.go
+1
-1
plugins/drivers/driver.go
with
406 additions
and
150 deletions
+406
-150
client/allocrunner/taskrunner/task_runner.go
+
2
-
0
View file @
129e6857
...
...
@@ -772,10 +772,12 @@ func (tr *TaskRunner) runDriver() error {
taskConfig
:=
tr
.
buildTaskConfig
()
if
tr
.
cpusetCgroupPathGetter
!=
nil
{
fmt
.
Println
(
"TaskRunner.runDriver, will wait for cpuset group"
)
cpusetCgroupPath
,
err
:=
tr
.
cpusetCgroupPathGetter
(
tr
.
killCtx
)
if
err
!=
nil
{
return
err
}
fmt
.
Println
(
"TaskRunner.runDriver, got cpuset group:"
,
cpusetCgroupPath
)
taskConfig
.
Resources
.
LinuxResources
.
CpusetCgroupPath
=
cpusetCgroupPath
}
...
...
This diff is collapsed.
Click to expand it.
client/config/config.go
+
1
-
1
View file @
129e6857
...
...
@@ -774,7 +774,7 @@ func DefaultConfig() *Config {
CNIConfigDir
:
"/opt/cni/config"
,
CNIInterfacePrefix
:
"eth"
,
HostNetworks
:
map
[
string
]
*
structs
.
ClientHostNetworkConfig
{},
CgroupParent
:
cgutil
.
Defaul
tCgroup
V1
Parent
,
CgroupParent
:
cgutil
.
Ge
tCgroupParent
(
""
)
,
MaxDynamicPort
:
structs
.
DefaultMinDynamicPort
,
MinDynamicPort
:
structs
.
DefaultMaxDynamicPort
,
}
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cgutil_linux.go
+
46
-
2
View file @
129e6857
...
...
@@ -7,9 +7,20 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/opencontainers/runc/libcontainer/cgroups"
lcc
"github.com/opencontainers/runc/libcontainer/configs"
"golang.org/x/sys/unix"
)
// 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
// of cgroups will be used.
func
GetCgroupParent
(
parent
string
)
string
{
if
cgroups
.
IsCgroup2UnifiedMode
()
{
return
v2GetParent
(
parent
)
}
return
getParentV1
(
parent
)
}
// CreateCPUSetManager creates a V1 or V2 CpusetManager depending on system configuration.
func
CreateCPUSetManager
(
parent
string
,
logger
hclog
.
Logger
)
CpusetManager
{
if
cgroups
.
IsCgroup2UnifiedMode
()
{
...
...
@@ -25,6 +36,37 @@ func GetCPUsFromCgroup(group string) ([]uint16, error) {
return
getCPUsFromCgroupV1
(
getParentV1
(
group
))
}
func
CgroupID
(
allocID
,
task
string
)
string
{
if
allocID
==
""
||
task
==
""
{
panic
(
"empty alloc or task"
)
}
if
cgroups
.
IsCgroup2UnifiedMode
()
{
return
fmt
.
Sprintf
(
"%s.%s.scope"
,
allocID
,
task
)
}
return
fmt
.
Sprintf
(
"%s.%s"
,
task
,
allocID
)
}
func
ConfigureBasicCgroups
(
cgroup
string
,
config
*
lcc
.
Config
)
error
{
if
cgroups
.
IsCgroup2UnifiedMode
()
{
panic
(
"do not call me for cgroups.v2"
)
}
// In V1 we must setup the freezer cgroup ourselves
subsystem
:=
"freezer"
path
,
err
:=
getCgroupPathHelper
(
subsystem
,
filepath
.
Join
(
DefaultCgroupV1Parent
,
cgroup
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to find %s cgroup mountpoint: %v"
,
subsystem
,
err
)
}
if
err
=
os
.
MkdirAll
(
path
,
0755
);
err
!=
nil
{
return
err
}
config
.
Cgroups
.
Paths
=
map
[
string
]
string
{
subsystem
:
path
,
}
return
nil
}
func
getCpusetSubsystemSettings
(
parent
string
)
(
cpus
,
mems
string
,
err
error
)
{
if
cpus
,
err
=
cgroups
.
ReadFile
(
parent
,
"cpuset.cpus"
);
err
!=
nil
{
return
...
...
@@ -111,8 +153,10 @@ func getCgroupPathHelper(subsystem, cgroup string) (string, error) {
return
""
,
err
}
fmt
.
Println
(
"SH C"
)
return
filepath
.
Join
(
mnt
,
relCgroup
),
nil
result
:=
filepath
.
Join
(
mnt
,
relCgroup
)
fmt
.
Println
(
"SH getCgroupPathHelper"
,
result
)
return
result
,
nil
}
// FindCgroupMountpointDir is used to find the cgroup mount point on a Linux
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager.go
+
6
-
4
View file @
129e6857
...
...
@@ -8,10 +8,10 @@ import (
)
// CpusetManager is used to setup cpuset cgroups for each task. A pool of shared cpus is managed for
//
tasks
which don't require any reserved cores and a cgroup is managed secretly for each task which
//
allocToInfo
which don't require any reserved cores and a cgroup is managed secretly for each task which
// require reserved cores.
type
CpusetManager
interface
{
// Init should be called before any
tasks
are managed to ensure the cgroup parent exists and
// Init should be called before any
allocToInfo
are managed to ensure the cgroup parent exists and
// check that proper permissions are granted to manage cgroups.
Init
()
error
...
...
@@ -42,8 +42,10 @@ func (n NoopCpusetManager) CgroupPathFor(allocID, task string) CgroupPathGetter
return
func
(
context
.
Context
)
(
string
,
error
)
{
return
""
,
nil
}
}
// CgroupPathGetter is a function which returns the cgroup path and any error which ocured during cgroup initialization.
// It should block until the cgroup has been created or an error is reported
// CgroupPathGetter is a function which returns the cgroup path and any error which
// occurred during cgroup initialization.
//
// It should block until the cgroup has been created or an error is reported.
type
CgroupPathGetter
func
(
context
.
Context
)
(
path
string
,
err
error
)
type
TaskCgroupInfo
struct
{
...
...
This diff is collapsed.
Click to expand it.
client/lib/cgutil/cpuset_manager_v2_linux.go
+
174
-
46
View file @
129e6857
...
...
@@ -5,54 +5,68 @@ import (
"fmt"
"path/filepath"
"sync"
"time"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/lib/cpuset"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"github.com/opencontainers/runc/libcontainer/configs"
)
const
(
// V2defaultCgroupParent is the name of Nomad's default parent cgroup, under which
// all other cgroups are managed. This can be changed with client configuration
// in case for e.g. Nomad tasks should be further constrained by an externally
// configured systemd cgroup.
V2defaultCgroupParent
=
"nomad.slice"
// v2CgroupRoot is hard-coded in the cgroups.v2 specification
// v2SharedCgroup is the name of Nomad's shared cgroup.
v2SharedCgroup
=
"shared.scope"
// v2ReservedCgroup is the name of Nomad's reserved cgroup.
//
// Tasks which reserve cores will have a cgroup created underneath.
v2ReservedCgroup
=
"reserved.slice"
// v2CgroupRoot is hard-coded in the cgroups.v2 specification.
v2CgroupRoot
=
"/sys/fs/cgroup"
// v2isRootless is (for now) always false; Nomad clients require root
// v2isRootless is (for now) always false; Nomad clients require root
.
v2isRootless
=
false
// v2CreationPID is a special PID in libcontainer
/cgroups
used to denote a
//
cgroup
// v2CreationPID is a special PID in libcontainer used to denote a
cgroup
//
should be created, but with no process added.
v2CreationPID
=
-
1
)
func
NewCpusetManagerV2
(
parent
string
,
logger
hclog
.
Logger
)
CpusetManager
{
cgroupParent
:=
v2GetParent
(
parent
)
return
&
cpusetManagerV2
{
ctx
:
context
.
TODO
(),
parent
:
v2GetParent
(
parent
),
logger
:
logger
,
ctx
:
context
.
TODO
(),
parent
:
cgroupParent
,
parentAbs
:
filepath
.
Join
(
v2CgroupRoot
,
cgroupParent
),
logger
:
logger
,
tracker
:
&
cgroupTracker
{
allocToInfo
:
make
(
map
[
string
]
allocTaskCgroupInfo
),
},
}
}
type
cpusetManagerV2
struct
{
ctx
context
.
Context
logger
hclog
.
Logger
parent
string
mgr
cgroups
.
Manager
lock
sync
.
Mutex
allocations
map
[
string
]
allocTaskCgroupInfo
ctx
context
.
Context
logger
hclog
.
Logger
tracker
*
cgroupTracker
parent
string
// relative to cgroup root (e.g. "nomad.slice")
parentAbs
string
// absolute path (e.g. "/sys/fs/cgroup/nomad.slice")
}
func
(
c
*
cpusetManagerV2
)
Init
()
error
{
fmt
.
Println
(
"SH mgr V2 Iinit"
)
if
err
:=
c
.
initHierarchy
();
err
!=
nil
{
c
.
logger
.
Error
(
"failed to init cpuset manager"
,
"err"
,
err
)
return
err
}
return
nil
}
...
...
@@ -61,20 +75,95 @@ func (c *cpusetManagerV2) AddAlloc(alloc *structs.Allocation) {
return
}
c
.
logger
.
Trace
(
"add allocation"
,
"name"
,
alloc
.
Name
,
"id"
,
alloc
.
ID
)
//for task, resources := range alloc.AllocatedResources.Tasks {
// taskCpuset := cpuset.New(resources.Cpu.ReservedCores...)
//
//}
// alloc.Resources.Cores
info
:=
make
(
allocTaskCgroupInfo
)
for
task
,
resources
:=
range
alloc
.
AllocatedResources
.
Tasks
{
taskCpuset
:=
cpuset
.
New
(
resources
.
Cpu
.
ReservedCores
...
)
// todo, uh what about all this
// absPath := filepath.Join(c.parentAbs, v2SharedCgroup)
// relPath := filepath.Join(c.parent, v2SharedCgroup)
// if !taskCpuset.Empty() {
// absPath, relPath = c.pathsForTask(alloc.ID, task)
// }
id
:=
CgroupID
(
alloc
.
ID
,
task
)
absPath
:=
filepath
.
Join
(
c
.
parentAbs
,
id
)
relPath
:=
filepath
.
Join
(
c
.
parent
,
id
)
info
[
task
]
=
&
TaskCgroupInfo
{
CgroupPath
:
absPath
,
RelativeCgroupPath
:
relPath
,
Cpuset
:
taskCpuset
,
}
}
c
.
tracker
.
set
(
alloc
.
ID
,
info
)
// todo: reconcile
c
.
reconcile
()
}
func
(
c
cpusetManagerV2
)
pathsForTask
(
allocID
,
task
string
)
(
string
,
string
)
{
name
:=
fmt
.
Sprintf
(
"%s-%s"
,
allocID
,
task
)
absPath
:=
filepath
.
Join
(
c
.
parentAbs
,
v2ReservedCgroup
,
name
)
relPath
:=
filepath
.
Join
(
c
.
parent
,
v2ReservedCgroup
,
name
)
return
absPath
,
relPath
}
func
(
c
*
cpusetManagerV2
)
RemoveAlloc
(
allocID
string
)
{
panic
(
"implement me"
)
c
.
logger
.
Trace
(
"remove allocation"
,
"id"
,
allocID
)
c
.
tracker
.
delete
(
allocID
)
}
func
(
c
*
cpusetManagerV2
)
CgroupPathFor
(
allocID
,
taskName
string
)
CgroupPathGetter
{
panic
(
"implement me"
)
func
(
c
*
cpusetManagerV2
)
CgroupPathFor
(
allocID
,
task
string
)
CgroupPathGetter
{
c
.
logger
.
Trace
(
"cgroup path for"
,
"id"
,
allocID
,
"task"
,
task
)
fmt
.
Println
(
"CPF want CgroupPathFor id:"
,
allocID
,
"task"
,
task
)
return
func
(
ctx
context
.
Context
)
(
string
,
error
)
{
ticker
,
cancel
:=
helper
.
NewSafeTimer
(
100
*
time
.
Millisecond
)
defer
cancel
()
for
{
taskInfo
:=
c
.
tracker
.
get
(
allocID
,
task
)
if
taskInfo
==
nil
{
fmt
.
Println
(
"CPF task info is nil for id:"
,
allocID
,
"task:"
,
task
)
return
""
,
fmt
.
Errorf
(
"cgroup not found for %s-%s"
,
allocID
,
task
)
}
if
taskInfo
.
Error
!=
nil
{
fmt
.
Println
(
"CPF task info error:"
,
taskInfo
.
Error
)
return
taskInfo
.
CgroupPath
,
taskInfo
.
Error
}
mgr
,
err
:=
fs2
.
NewManager
(
nil
,
taskInfo
.
CgroupPath
,
v2isRootless
)
if
err
!=
nil
{
fmt
.
Println
(
"CPF new manager error:"
,
err
)
return
""
,
err
}
if
mgr
.
Exists
()
{
fmt
.
Println
(
"CPF exists! id:"
,
allocID
,
"task:"
,
task
,
"path:"
,
taskInfo
.
CgroupPath
)
return
taskInfo
.
CgroupPath
,
nil
}
select
{
case
<-
ctx
.
Done
()
:
fmt
.
Println
(
"CPF context done, id:"
,
allocID
,
"task:"
,
task
,
"error:"
,
ctx
.
Err
())
return
taskInfo
.
CgroupPath
,
ctx
.
Err
()
case
<-
ticker
.
C
:
continue
}
}
}
}
func
(
c
*
cpusetManagerV2
)
reconcile
()
{
c
.
tracker
.
walk
(
func
(
info
*
TaskCgroupInfo
)
{
mgr
,
err
:=
fs2
.
NewManager
(
nil
,
info
.
CgroupPath
,
v2isRootless
)
if
err
!=
nil
{
panic
(
err
)
}
if
err
=
mgr
.
Apply
(
v2CreationPID
);
err
!=
nil
{
panic
(
err
)
}
})
}
func
(
c
*
cpusetManagerV2
)
getParent
()
string
{
...
...
@@ -82,22 +171,20 @@ func (c *cpusetManagerV2) getParent() string {
}
func
(
c
*
cpusetManagerV2
)
initHierarchy
()
error
{
cfg
:=
&
configs
.
Cgroup
{}
parent
:=
c
.
getParent
()
// Create parent cgroup
mgr
,
err
:=
fs2
.
NewManager
(
cfg
,
parent
,
v2isRootless
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to setup cgroup hierarchy: %w"
,
err
)
fmt
.
Println
(
"SH create:"
,
c
.
parentAbs
)
parentMgr
,
parentErr
:=
fs2
.
NewManager
(
nil
,
c
.
parentAbs
,
v2isRootless
)
if
parentErr
!=
nil
{
return
parentErr
}
c
.
mgr
=
mgr
if
err
=
c
.
mgr
.
Apply
(
v2CreationPID
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to apply initial cgroup hierarchy: %w"
,
err
)
if
applyParentErr
:=
parentMgr
.
Apply
(
v2CreationPID
);
applyParentErr
!=
nil
{
return
applyParentErr
}
fmt
.
Println
(
"SH created parent"
)
c
.
logger
.
Debug
(
"established cgroup hierarchy"
,
"parent"
,
p
arent
)
c
.
logger
.
Debug
(
"established
initial
cgroup hierarchy"
,
"parent"
,
c
.
getP
arent
()
)
return
nil
}
...
...
@@ -107,24 +194,14 @@ func v2Root(group string) string {
func
v2GetCPUsFromCgroup
(
group
string
)
([]
uint16
,
error
)
{
path
:=
v2Root
(
group
)
fmt
.
Println
(
"SH v2GetCPUsFromCgroup, group:"
,
group
,
"path:"
,
path
)
effective
,
err
:=
cgroups
.
ReadFile
(
path
,
"cpuset.cpus.effective"
)
if
err
!=
nil
{
fmt
.
Println
(
"A err:"
,
err
)
return
nil
,
err
}
fmt
.
Println
(
"B effective:"
,
effective
)
set
,
err
:=
cpuset
.
Parse
(
effective
)
if
err
!=
nil
{
fmt
.
Println
(
"C: parse:"
,
err
)
return
nil
,
err
}
fmt
.
Println
(
"D: set:"
,
set
)
return
set
.
ToSlice
(),
nil
}
...
...
@@ -134,3 +211,54 @@ func v2GetParent(parent string) string {
}
return
parent
}
type
cgroupTracker
struct
{
lock
sync
.
RWMutex
allocToInfo
map
[
string
]
allocTaskCgroupInfo
}
func
(
cm
*
cgroupTracker
)
set
(
allocID
string
,
info
allocTaskCgroupInfo
)
{
cm
.
lock
.
Lock
()
defer
cm
.
lock
.
Unlock
()
cm
.
allocToInfo
[
allocID
]
=
info
}
func
(
cm
*
cgroupTracker
)
delete
(
allocID
string
)
{
cm
.
lock
.
Lock
()
defer
cm
.
lock
.
Unlock
()
delete
(
cm
.
allocToInfo
,
allocID
)
}
func
(
cm
*
cgroupTracker
)
get
(
allocID
,
task
string
)
*
TaskCgroupInfo
{
cm
.
lock
.
RLock
()
defer
cm
.
lock
.
RUnlock
()
allocInfo
,
allocExists
:=
cm
.
allocToInfo
[
allocID
]
if
!
allocExists
{
return
nil
}
taskInfo
,
taskExists
:=
allocInfo
[
task
]
if
!
taskExists
{
return
nil
}
return
&
TaskCgroupInfo
{
CgroupPath
:
taskInfo
.
CgroupPath
,
RelativeCgroupPath
:
taskInfo
.
RelativeCgroupPath
,
Cpuset
:
taskInfo
.
Cpuset
.
Copy
(),
Error
:
taskInfo
.
Error
,
}
}
func
(
cm
*
cgroupTracker
)
walk
(
f
func
(
info
*
TaskCgroupInfo
))
{
cm
.
lock
.
RLock
()
defer
cm
.
lock
.
RUnlock
()
for
alloc
,
taskInfo
:=
range
cm
.
allocToInfo
{
for
task
,
info
:=
range
taskInfo
{
fmt
.
Println
(
"walk, alloc:"
,
alloc
,
"task:"
,
task
,
"path:"
,
info
.
CgroupPath
)
f
(
info
)
}
}
}
This diff is collapsed.
Click to expand it.
command/agent/agent.go
+
3
-
0
View file @
129e6857
...
...
@@ -894,6 +894,9 @@ func (a *Agent) setupClient() error {
return
fmt
.
Errorf
(
"client setup failed: %v"
,
err
)
}
// todo remove
fmt
.
Println
(
"SH client.conf reservable_cores:"
,
conf
.
ReservableCores
)
// Reserve some ports for the plugins if we are on Windows
if
runtime
.
GOOS
==
"windows"
{
if
err
:=
a
.
reservePortsForClient
(
conf
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
drivers/exec/driver.go
+
6
-
0
View file @
129e6857
...
...
@@ -359,6 +359,8 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
return
fp
}
fmt
.
Println
(
"SH exec mount:"
,
mount
)
if
mount
==
""
{
fp
.
Health
=
drivers
.
HealthStateUnhealthy
fp
.
HealthDescription
=
drivers
.
CgroupMountEmpty
...
...
@@ -498,8 +500,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
ModePID
:
executor
.
IsolationMode
(
d
.
config
.
DefaultModePID
,
driverConfig
.
ModePID
),
ModeIPC
:
executor
.
IsolationMode
(
d
.
config
.
DefaultModeIPC
,
driverConfig
.
ModeIPC
),
Capabilities
:
caps
,
AllocID
:
cfg
.
AllocID
,
Task
:
cfg
.
Name
,
}
fmt
.
Println
(
"SH driver.StartTask, exec:"
,
execCmd
.
Cmd
)
ps
,
err
:=
exec
.
Launch
(
execCmd
)
if
err
!=
nil
{
pluginClient
.
Kill
()
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/executor.go
+
10
-
1
View file @
129e6857
...
...
@@ -154,6 +154,12 @@ type ExecCommand struct {
// Capabilities are the linux capabilities to be enabled by the task driver.
Capabilities
[]
string
// AllocID the allocation ID for which this command is being executed.
AllocID
string
// Task the task name for which this command is being executed.
Task
string
}
// SetWriters sets the writer for the process stdout and stderr. This should
...
...
@@ -302,7 +308,10 @@ func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error)
// Setup cgroups on linux
if
e
.
commandCfg
.
ResourceLimits
||
e
.
commandCfg
.
BasicProcessCgroup
{
if
err
:=
e
.
configureResourceContainer
(
os
.
Getpid
());
err
!=
nil
{
pid
:=
os
.
Getpid
()
allocID
:=
command
.
AllocID
taskName
:=
command
.
Task
if
err
:=
e
.
configureResourceContainer
(
pid
,
allocID
,
taskName
);
err
!=
nil
{
return
nil
,
err
}
}
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/executor_linux.go
+
45
-
26
View file @
129e6857
...
...
@@ -19,6 +19,7 @@ import (
"github.com/hashicorp/consul-template/signals"
hclog
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/lib/cgutil"
"github.com/hashicorp/nomad/client/stats"
cstructs
"github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/capabilities"
...
...
@@ -68,9 +69,20 @@ type LibcontainerExecutor struct {
userProc
*
libcontainer
.
Process
userProcExited
chan
interface
{}
exitState
*
ProcessState
debug
*
os
.
File
}
func
NewExecutorWithIsolation
(
logger
hclog
.
Logger
)
Executor
{
debug
,
err
:=
os
.
OpenFile
(
"/tmp/debug.log"
,
os
.
O_CREATE
|
os
.
O_TRUNC
|
os
.
O_WRONLY
,
0655
)
if
err
!=
nil
{
panic
(
err
)
}
dlog
:=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
Output
:
debug
,
Name
:
"exec"
,
})
logger
=
logger
.
Named
(
"isolated_executor"
)
if
err
:=
shelpers
.
Init
();
err
!=
nil
{
...
...
@@ -78,15 +90,20 @@ func NewExecutorWithIsolation(logger hclog.Logger) Executor {
}
return
&
LibcontainerExecutor
{
id
:
strings
.
ReplaceAll
(
uuid
.
Generate
(),
"-"
,
"_"
),
logger
:
log
ger
,
logger
:
d
log
,
totalCpuStats
:
stats
.
NewCpuStats
(),
userCpuStats
:
stats
.
NewCpuStats
(),
systemCpuStats
:
stats
.
NewCpuStats
(),
pidCollector
:
newPidCollector
(
logger
),
debug
:
debug
,
}
}
// Launch creates a new container in libcontainer and starts a new process with it
//
// BTW, logging and printing does nothing here, this is being running in a sub-process.
// For debugging, try writing to a file.
func
(
l
*
LibcontainerExecutor
)
Launch
(
command
*
ExecCommand
)
(
*
ProcessState
,
error
)
{
l
.
logger
.
Trace
(
"preparing to launch command"
,
"command"
,
command
.
Cmd
,
"args"
,
strings
.
Join
(
command
.
Args
,
" "
))
...
...
@@ -111,6 +128,9 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro
return
nil
,
fmt
.
Errorf
(
"failed to create factory: %v"
,
err
)
}
// FIND THIS
l
.
logger
.
Info
(
"LibcontainerExecutor.Launch"
,
"cmd"
,
command
.
Cmd
,
"alloc_id"
,
command
.
AllocID
,
"task"
,
command
.
Task
)
// A container groups processes under the same isolation enforcement
containerCfg
,
err
:=
newLibcontainerConfig
(
command
)
if
err
!=
nil
{
...
...
@@ -271,6 +291,10 @@ func (l *LibcontainerExecutor) wait() {
// Shutdown stops all processes started and cleans up any resources
// created (such as mountpoints, devices, etc).
func
(
l
*
LibcontainerExecutor
)
Shutdown
(
signal
string
,
grace
time
.
Duration
)
error
{
l
.
logger
.
Info
(
"shutdown"
)
_
=
l
.
debug
.
Sync
()
_
=
l
.
debug
.
Close
()
if
l
.
container
==
nil
{
return
nil
}
...
...
@@ -665,14 +689,30 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) error {
}
func
configureCgroups
(
cfg
*
lconfigs
.
Config
,
command
*
ExecCommand
)
error
{
f
,
err
:=
os
.
OpenFile
(
"/tmp/cc.log"
,
os
.
O_CREATE
|
os
.
O_TRUNC
|
os
.
O_WRONLY
,
0666
)
if
err
!=
nil
{
panic
(
err
)
}
defer
func
()
{
_
=
f
.
Sync
()
_
=
f
.
Close
()
}()
logger
:=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
Output
:
f
,
})
id
:=
cgutil
.
CgroupID
(
command
.
AllocID
,
command
.
Task
)
logger
.
Info
(
"configureCgroups"
,
"id"
,
id
)
// If resources are not limited then manually create cgroups needed
if
!
command
.
ResourceLimits
{
return
configureBasicCgroups
(
cfg
)
return
c
gutil
.
C
onfigureBasicCgroups
(
id
,
cfg
)
}
id
:=
uuid
.
Generate
()
cfg
.
Cgroups
.
Path
=
filepath
.
Join
(
"/"
,
defaultCgroupParent
,
id
)
cfg
.
Cgroups
.
Path
=
filepath
.
Join
(
"/"
,
cgutil
.
GetCgroupParent
(
cfg
.
Cgroups
.
Parent
),
id
)
fmt
.
Println
(
"SH has cmd resource limits, not basic, id:"
,
id
,
"cgroups.path:"
,
cfg
.
Cgroups
.
Path
)
if
command
.
Resources
==
nil
||
command
.
Resources
.
NomadResources
==
nil
{
return
nil
...
...
@@ -715,28 +755,6 @@ func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error {
return
nil
}
func
configureBasicCgroups
(
cfg
*
lconfigs
.
Config
)
error
{
id
:=
uuid
.
Generate
()
// Manually create freezer cgroup
subsystem
:=
"freezer"
path
,
err
:=
getCgroupPathHelper
(
subsystem
,
filepath
.
Join
(
defaultCgroupParent
,
id
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to find %s cgroup mountpoint: %v"
,
subsystem
,
err
)
}
if
err
=
os
.
MkdirAll
(
path
,
0755
);
err
!=
nil
{
return
err
}
cfg
.
Cgroups
.
Paths
=
map
[
string
]
string
{
subsystem
:
path
,
}
return
nil
}
func
getCgroupPathHelper
(
subsystem
,
cgroup
string
)
(
string
,
error
)
{
mnt
,
root
,
err
:=
cgroups
.
FindCgroupMountpointAndRoot
(
""
,
subsystem
)
if
err
!=
nil
{
...
...
@@ -888,6 +906,7 @@ func lookPathIn(path string, root string, bin string) (string, error) {
}
func
newSetCPUSetCgroupHook
(
cgroupPath
string
)
lconfigs
.
Hook
{
fmt
.
Println
(
"SH newSetCPUSetCgroupHook, cgroupPath:"
,
cgroupPath
)
return
lconfigs
.
NewFunctionHook
(
func
(
state
*
specs
.
State
)
error
{
return
cgroups
.
WriteCgroupProc
(
cgroupPath
,
state
.
Pid
)
})
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/executor_universal_linux.go
+
5
-
3
View file @
129e6857
...
...
@@ -10,6 +10,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
multierror
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/lib/cgutil"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupFs
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
...
...
@@ -67,7 +68,7 @@ func setCmdUser(cmd *exec.Cmd, userid string) error {
// configureResourceContainer configured the cgroups to be used to track pids
// created by the executor
func
(
e
*
UniversalExecutor
)
configureResourceContainer
(
pid
int
)
error
{
func
(
e
*
UniversalExecutor
)
configureResourceContainer
(
pid
int
,
allocID
,
task
string
)
error
{
cfg
:=
&
lconfigs
.
Config
{
Cgroups
:
&
lconfigs
.
Cgroup
{
Resources
:
&
lconfigs
.
Resources
{},
...
...
@@ -77,8 +78,9 @@ func (e *UniversalExecutor) configureResourceContainer(pid int) error {
cfg
.
Cgroups
.
Resources
.
Devices
=
append
(
cfg
.
Cgroups
.
Resources
.
Devices
,
&
device
.
Rule
)
}
err
:=
configureBasicCgroups
(
cfg
)
if
err
!=
nil
{
// need allocID and task name
cgroupID
:=
cgutil
.
CgroupID
(
allocID
,
task
)
if
err
:=
cgutil
.
ConfigureBasicCgroups
(
cgroupID
,
cfg
);
err
!=
nil
{
// Log this error to help diagnose cases where nomad is run with too few
// permissions, but don't return an error. There is no separate check for
// cgroup creation permissions, so this may be the happy path.
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/client.go
→
drivers/shared/executor/
grpc_
client.go
+
3
-
0
View file @
129e6857
...
...
@@ -31,6 +31,7 @@ type grpcExecutorClient struct {
}
func
(
c
*
grpcExecutorClient
)
Launch
(
cmd
*
ExecCommand
)
(
*
ProcessState
,
error
)
{
fmt
.
Println
(
"SH grpc.Launch cmd:"
,
cmd
.
Cmd
,
"id:"
,
cmd
.
AllocID
,
"task:"
,
cmd
.
Task
)
ctx
:=
context
.
Background
()
req
:=
&
proto
.
LaunchRequest
{
Cmd
:
cmd
.
Cmd
,
...
...
@@ -50,6 +51,8 @@ func (c *grpcExecutorClient) Launch(cmd *ExecCommand) (*ProcessState, error) {
DefaultPidMode
:
cmd
.
ModePID
,
DefaultIpcMode
:
cmd
.
ModeIPC
,
Capabilities
:
cmd
.
Capabilities
,
AllocId
:
cmd
.
AllocID
,
TaskName
:
cmd
.
Task
,
}
resp
,
err
:=
c
.
client
.
Launch
(
ctx
,
req
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/server.go
→
drivers/shared/executor/
grpc_
server.go
+
3
-
0
View file @
129e6857
...
...
@@ -20,6 +20,7 @@ type grpcExecutorServer struct {
}
func
(
s
*
grpcExecutorServer
)
Launch
(
ctx
context
.
Context
,
req
*
proto
.
LaunchRequest
)
(
*
proto
.
LaunchResponse
,
error
)
{
fmt
.
Println
(
"grpc.Launch, id:"
,
req
.
AllocId
,
"task:"
,
req
.
TaskName
)
ps
,
err
:=
s
.
impl
.
Launch
(
&
ExecCommand
{
Cmd
:
req
.
Cmd
,
Args
:
req
.
Args
,
...
...
@@ -38,6 +39,8 @@ func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchReques
ModePID
:
req
.
DefaultPidMode
,
ModeIPC
:
req
.
DefaultIpcMode
,
Capabilities
:
req
.
Capabilities
,
AllocID
:
req
.
AllocId
,
Task
:
req
.
TaskName
,
})
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/proto/executor.pb.go
+
83
-
66
View file @
129e6857
...
...
@@ -46,6 +46,8 @@ type LaunchRequest struct {
CpusetCgroup
string
`protobuf:"bytes,17,opt,name=cpuset_cgroup,json=cpusetCgroup,proto3" json:"cpuset_cgroup,omitempty"`
AllowCaps
[]
string
`protobuf:"bytes,18,rep,name=allow_caps,json=allowCaps,proto3" json:"allow_caps,omitempty"`
Capabilities
[]
string
`protobuf:"bytes,19,rep,name=capabilities,proto3" json:"capabilities,omitempty"`
AllocId
string
`protobuf:"bytes,20,opt,name=alloc_id,json=allocId,proto3" json:"alloc_id,omitempty"`
TaskName
string
`protobuf:"bytes,21,opt,name=task_name,json=taskName,proto3" json:"task_name,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
...
@@ -209,6 +211,20 @@ func (m *LaunchRequest) GetCapabilities() []string {
return
nil
}
func
(
m
*
LaunchRequest
)
GetAllocId
()
string
{
if
m
!=
nil
{
return
m
.
AllocId
}
return
""
}
func
(
m
*
LaunchRequest
)
GetTaskName
()
string
{
if
m
!=
nil
{
return
m
.
TaskName
}
return
""
}
type
LaunchResponse
struct
{
Process
*
ProcessState
`protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
...
...
@@ -874,74 +890,75 @@ func init() {
}
var
fileDescriptor_66b85426380683f3
=
[]
byte
{
// 10
5
8 bytes of a gzipped FileDescriptorProto
// 10
8
8 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xb4
,
0x55
,
0x6d
,
0x6f
,
0x1b
,
0x45
,
0x10
,
0xee
,
0xc5
,
0x89
,
0x5f
,
0xc6
,
0x76
,
0xe2
,
0x2e
,
0x
a8
,
0x5c
,
0x8d
,
0x50
,
0xcd
,
0x21
,
0x51
,
0x0b
,
0xca
,
0x25
,
0x4a
,
0xdf
,
0x90
,
0x90
,
0x28
,
0x22
,
0x2
d
,
0x
a
8
,
0x52
,
0x1a
,
0x45
,
0x97
,
0x42
,
0x10
,
0xee
,
0xc5
,
0x89
,
0x5f
,
0xc6
,
0x76
,
0xe2
,
0x2e
,
0x
25
,
0x5c
,
0x8d
,
0x50
,
0xcd
,
0x21
,
0x51
,
0x0b
,
0xca
,
0x25
,
0x4a
,
0xdf
,
0x90
,
0x90
,
0x28
,
0x22
,
0x2
9
,
0x
2
8
,
0x52
,
0x1a
,
0x45
,
0x97
,
0x42
,
0x25
,
0x3e
,
0x70
,
0x6c
,
0xee
,
0xb6
,
0xf6
,
0x2a
,
0xf6
,
0xed
,
0xb2
,
0xbb
,
0xe7
,
0x04
,
0x09
,
0x89
,
0x4f
,
0xfc
,
0x03
,
0x90
,
0xf8
,
0x31
,
0xfc
,
0x38
,
0xb4
,
0x6f
,
0x17
,
0x3b
,
0x2d
,
0xd5
,
0xb9
,
0x88
,
0x4f
,
0xbe
,
0x1d
,
0x3f
,
0xcf
,
0xcc
,
0xec
,
0xce
,
0xcc
,
0x33
,
0x70
,
0x27
,
0x17
,
0x74
,
0x41
,
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
0x79
,
0xf3
,
0xec
,
0x97
,
0xb0
,
0x61
,
0x74
,
0x01
,
0x55
,
0x6e
,
0xeb
,
0xa2
,
0x76
,
0xf5
,
0x1f
,
0xae
,
0xc8
,
0xf2
,
0x79
,
0x77
,
0x03
,
0x3d
,
0xff
,
0x56
,
0x58
,
0xaa
,
0xcf
,
0xff
,
0x92
,
0x62
,
0x55
,
0x9f
,
0xff
,
0x6b
,
0xfa
,
0x65
,
0xe6
,
0x5f
,
0xaf
,
0x61
,
0xf5
,
0xf9
,
0x5f
,
0xd0
,
0xbb
,
0xea
,
0xf3
,
0xbf
,
0xa8
,
0x5b
,
0xd1
,
0x0d
,
0xf4
,
0x57
,
0x00
,
0x5d
,
0xed
,
0x3a
,
0x55
,
0x82
,
0xe0
,
0x29
,
0x2d
,
0x46
,
0xe8
,
0x49
,
0x45
,
0xf1
,
0xd6
,
0x2c
,
0x2b
,
0xe0
,
0x8e
,
0xe9
,
0x4b
,
0xf9
,
0xea
,
0xed
,
0x03
,
0xf8
,
0xb2
,
0x86
,
0xc1
,
0x6e
,
0xf0
,
0x75
,
0xe3
,
0x87
,
0x0d
,
0xab
,
0x59
,
0x75
,
0xf3
,
0x73
,
0xff
,
0x9f
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0xff
,
0x0e
,
0xfa
,
0x9c
,
0xac
,
0x0c
,
0x00
,
0x00
,
}
// Reference imports to suppress errors if they are not otherwise used.
...
...
This diff is collapsed.
Click to expand it.
drivers/shared/executor/proto/executor.proto
+
2
-
0
View file @
129e6857
...
...
@@ -47,6 +47,8 @@ message LaunchRequest {
string
cpuset_cgroup
=
17
;
repeated
string
allow_caps
=
18
;
repeated
string
capabilities
=
19
;
string
alloc_id
=
20
;
string
task_name
=
21
;
}
message
LaunchResponse
{
...
...
This diff is collapsed.
Click to expand it.
lib/cpuset/cpuset.go
+
16
-
0
View file @
129e6857
...
...
@@ -28,6 +28,17 @@ func New(cpus ...uint16) CPUSet {
return
cpuset
}
// Copy returns a deep copy of CPUSet c.
func
(
c
CPUSet
)
Copy
()
CPUSet
{
cpus
:=
make
(
map
[
uint16
]
struct
{},
len
(
c
.
cpus
))
for
k
:=
range
c
.
cpus
{
cpus
[
k
]
=
struct
{}{}
}
return
CPUSet
{
cpus
:
cpus
,
}
}
// String returns the cpuset as a comma delimited set of core values and ranged
func
(
c
CPUSet
)
String
()
string
{
if
c
.
Size
()
==
0
{
...
...
@@ -65,6 +76,11 @@ func (c CPUSet) Size() int {
return
len
(
c
.
cpus
)
}
// Empty returns whether any cpus are contained in the CPUSet.
func
(
c
CPUSet
)
Empty
()
bool
{
return
c
.
Size
()
<=
0
}
// ToSlice returns a sorted slice of uint16 CPU IDs contained in the CPUSet.
func
(
c
CPUSet
)
ToSlice
()
[]
uint16
{
cpus
:=
[]
uint16
{}
...
...
This diff is collapsed.
Click to expand it.
plugins/drivers/driver.go
+
1
-
1
View file @
129e6857
...
...
@@ -267,7 +267,7 @@ type TaskConfig struct {
JobName
string
JobID
string
TaskGroupName
string
Name
string
Name
string
// task.Name
Namespace
string
NodeName
string
NodeID
string
...
...
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