Skip to content

Commit

Permalink
Merge 7fcc172 into 49e38f5
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy authored Aug 1, 2023
2 parents 49e38f5 + 7fcc172 commit 3128294
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/remotecmd/kubeexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@ func (k *kubeExecProcessHandler) StartProcessForCommand(ctx context.Context, def
// Then killing those children will exit the parent 'sh' process.
func (k *kubeExecProcessHandler) StopProcessForCommand(ctx context.Context, def CommandDefinition, podName string, containerName string) error {
klog.V(4).Infof("StopProcessForCommand for %q", def.Id)
defer func() {
pidFile := getPidFileForCommand(def)
_, _, err := k.execClient.ExecuteCommand(ctx, []string{ShellExecutable, "-c", fmt.Sprintf("rm -f %s", pidFile)}, podName, containerName, false, nil, nil)
if err != nil {
klog.V(2).Infof("Could not remove file %q: %v", pidFile, err)
}
}()

kill := func(p int) error {
_, _, err := k.execClient.ExecuteCommand(ctx, []string{ShellExecutable, "-c", fmt.Sprintf("kill %d || true", p)}, podName, containerName, false, nil, nil)
Expand Down Expand Up @@ -181,6 +174,12 @@ func (k *kubeExecProcessHandler) StopProcessForCommand(ctx context.Context, def
return nil
}

pidFile := getPidFileForCommand(def)
_, _, err := k.execClient.ExecuteCommand(ctx, []string{ShellExecutable, "-c", fmt.Sprintf("rm -f %s", pidFile)}, podName, containerName, false, nil, nil)
if err != nil {
klog.V(2).Infof("Could not remove file %q: %v", pidFile, err)
}

ppid, _, err := k.getRemoteProcessPID(ctx, def, podName, containerName)
if err != nil {
return err
Expand Down

0 comments on commit 3128294

Please sign in to comment.