Skip to content

Commit 75bedf8

Browse files
committed
Merge pull request #855 from hashicorp/cgroups-pid
Updated logic for creation of cgroup
2 parents dbd815b + 71fb58c commit 75bedf8

File tree

220 files changed

+527
-25655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+527
-25655
lines changed

Godeps/Godeps.json

+190-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/driver/executor/executor_linux.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ func (e *UniversalExecutor) applyLimits(pid int) error {
8282
func (e *UniversalExecutor) configureCgroups(resources *structs.Resources) error {
8383
e.groups = &cgroupConfig.Cgroup{}
8484
e.groups.Resources = &cgroupConfig.Resources{}
85-
e.groups.Name = structs.GenerateUUID()
85+
cgroupName := structs.GenerateUUID()
86+
cgPath, err := cgroups.GetThisCgroupDir("devices")
87+
if err != nil {
88+
return fmt.Errorf("unable to get mount point for devices sub-system: %v", err)
89+
}
90+
e.groups.Path = filepath.Join(cgPath, cgroupName)
8691

8792
// TODO: verify this is needed for things like network access
8893
e.groups.Resources.AllowAllDevices = true
@@ -191,6 +196,12 @@ func DestroyCgroup(groups *cgroupConfig.Cgroup) error {
191196
manager := getCgroupManager(groups)
192197
if pids, perr := manager.GetPids(); perr == nil {
193198
for _, pid := range pids {
199+
// If the pid is the pid of the executor then we don't kill it, the
200+
// executor is going to be killed by the driver once the Wait
201+
// returns
202+
if pid == os.Getpid() {
203+
continue
204+
}
194205
proc, err := os.FindProcess(pid)
195206
if err != nil {
196207
merrs.Errors = append(merrs.Errors, fmt.Errorf("error finding process %v: %v", pid, err))
@@ -200,6 +211,8 @@ func DestroyCgroup(groups *cgroupConfig.Cgroup) error {
200211
}
201212
}
202213
}
214+
} else {
215+
merrs.Errors = append(merrs.Errors, fmt.Errorf("error getting pids: %v", perr))
203216
}
204217

205218
// Remove the cgroup.

0 commit comments

Comments
 (0)