mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #29676 from kubernetes/revert-29380-kill-setpgid
Revert "Fix killing child sudo process in e2e_node tests"
This commit is contained in:
commit
6456d67bd0
@ -26,6 +26,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -294,6 +295,18 @@ func (es *e2eService) startServer(cmd *healthCheckCommand) error {
|
|||||||
cmd.Cmd.Stdout = outfile
|
cmd.Cmd.Stdout = outfile
|
||||||
cmd.Cmd.Stderr = outfile
|
cmd.Cmd.Stderr = outfile
|
||||||
|
|
||||||
|
// Killing the sudo command should kill the server as well.
|
||||||
|
attrs := &syscall.SysProcAttr{}
|
||||||
|
// Hack to set linux-only field without build tags.
|
||||||
|
deathSigField := reflect.ValueOf(attrs).Elem().FieldByName("Pdeathsig")
|
||||||
|
if deathSigField.IsValid() {
|
||||||
|
deathSigField.Set(reflect.ValueOf(syscall.SIGKILL))
|
||||||
|
} else {
|
||||||
|
cmdErrorChan <- fmt.Errorf("Failed to set Pdeathsig field (non-linux build)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Cmd.SysProcAttr = attrs
|
||||||
|
|
||||||
// Run the command
|
// Run the command
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -359,10 +372,7 @@ func (k *killCmd) Kill() error {
|
|||||||
const timeout = 10 * time.Second
|
const timeout = 10 * time.Second
|
||||||
for _, signal := range []string{"-TERM", "-KILL"} {
|
for _, signal := range []string{"-TERM", "-KILL"} {
|
||||||
glog.V(2).Infof("Killing process %d (%s) with %s", pid, name, signal)
|
glog.V(2).Infof("Killing process %d (%s) with %s", pid, name, signal)
|
||||||
cmd := exec.Command("sudo", "kill", signal, strconv.Itoa(pid))
|
_, err := exec.Command("sudo", "kill", signal, strconv.Itoa(pid)).Output()
|
||||||
// Run the 'kill' command in a separate process group so sudo doesn't ignore it
|
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
||||||
_, err := cmd.Output()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error signaling process %d (%s) with %s: %v", pid, name, signal, err)
|
glog.Errorf("Error signaling process %d (%s) with %s: %v", pid, name, signal, err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user