From ada14a524d0640c24037a47f540dfeb7f3fe0b0f Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Fri, 4 Sep 2015 17:38:10 +0200 Subject: [PATCH] Fix compilation of Mesos minion on Mac --- contrib/mesos/pkg/minion/tasks/task.go | 5 +-- contrib/mesos/pkg/minion/tasks/task_linux.go | 28 +++++++++++++++ contrib/mesos/pkg/minion/tasks/task_other.go | 38 ++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 contrib/mesos/pkg/minion/tasks/task_linux.go create mode 100644 contrib/mesos/pkg/minion/tasks/task_other.go diff --git a/contrib/mesos/pkg/minion/tasks/task.go b/contrib/mesos/pkg/minion/tasks/task.go index 51dfcaf07f0..f6ddb52a9e6 100644 --- a/contrib/mesos/pkg/minion/tasks/task.go +++ b/contrib/mesos/pkg/minion/tasks/task.go @@ -214,10 +214,7 @@ func notStartedTask(t *Task) taskStateFn { if len(t.env) > 0 { cmd.Env = t.env } - cmd.SysProcAttr = &syscall.SysProcAttr{ - Setpgid: true, - Pdeathsig: syscall.SIGKILL, // see cmdProcess.Kill - } + cmd.SysProcAttr = sysProcAttr() // last min check for shouldQuit here select { diff --git a/contrib/mesos/pkg/minion/tasks/task_linux.go b/contrib/mesos/pkg/minion/tasks/task_linux.go new file mode 100644 index 00000000000..a570f85370c --- /dev/null +++ b/contrib/mesos/pkg/minion/tasks/task_linux.go @@ -0,0 +1,28 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tasks + +import ( + "syscall" +) + +func sysProcAttr() *syscall.SysProcAttr { + return &syscall.SysProcAttr{ + Setpgid: true, + Pdeathsig: syscall.SIGKILL, // see cmdProcess.Kill + } +} diff --git a/contrib/mesos/pkg/minion/tasks/task_other.go b/contrib/mesos/pkg/minion/tasks/task_other.go new file mode 100644 index 00000000000..a83c28a8536 --- /dev/null +++ b/contrib/mesos/pkg/minion/tasks/task_other.go @@ -0,0 +1,38 @@ +// +build !linux + +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tasks + +import ( + "syscall" +) + +func sysProcAttr() *syscall.SysProcAttr { + // TODO(jdef) + // Consequence of not having Pdeathdig is that on non-Linux systems, + // if SIGTERM doesn't stop child procs then they may "leak" and be + // reparented 'up the chain' somewhere when the minion process + // terminates. For example, such child procs end up living indefinitely + // as children of the mesos slave process (I think the slave could handle + // this case, but currently doesn't do it very well). Pdeathsig on Linux + // was a fallback/failsafe mechanism implemented to guard against this. I + // don't know if OS X has any syscalls that do something similar. + return &syscall.SysProcAttr{ + Setpgid: true, + } +}