Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9b1309e

Browse files
Ben Howardopenshift-merge-robot
Ben Howard
authored andcommittedDec 1, 2020
Gangplank: ensure minio always dies
With 6a84c3a `minioServer.kill` was added, which should have addressed the problem. To really make sure minio dies, this uses `exec.Cmd` `SysProcAttr` to kill when Gangplank dies. Fixes: #1869 Signed-off-by: Ben Howard <[email protected]>
1 parent 3eb02c3 commit 9b1309e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎gangplank/ocp/filer.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ func (m *minioServer) start(ctx context.Context) error {
131131

132132
args := []string{mpath, "server", m.dir}
133133
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
134+
cmd.SysProcAttr = &syscall.SysProcAttr{
135+
Foreground: false, // Background the process
136+
Pdeathsig: syscall.SIGTERM, // Let minio finish before killing
137+
Pgid: 0, // Use the pid of the minio as the pgroup id
138+
Setpgid: true, // Set the pgroup
139+
}
134140
cmd.Env = append(
135141
os.Environ(),
136142
fmt.Sprintf("MINIO_ACCESS_KEY=%s", m.AccessKey),
@@ -163,7 +169,10 @@ func (m *minioServer) kill() {
163169
if m.cmd == nil {
164170
return
165171
}
166-
_ = m.cmd.Process.Kill()
172+
// Note the "-" before the processes PID. A negative pid to
173+
// syscall.Kill kills the processes Pid group ensuring all forks/execs
174+
// of minio are killed too.
175+
_ = syscall.Kill(-m.cmd.Process.Pid, syscall.SIGTERM)
167176
}
168177

169178
func randomString(n int) (string, error) {

0 commit comments

Comments
 (0)
Please sign in to comment.