Skip to content

Commit

Permalink
Revert "fix: Correct kill command. Fixes #8687 (#8908)"
Browse files Browse the repository at this point in the history
This reverts commit ef3fb42.
  • Loading branch information
sarabala1979 committed Aug 9, 2022
1 parent b7b37d5 commit 5db53aa
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 64 deletions.
37 changes: 0 additions & 37 deletions cmd/argoexec/commands/kill.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/argoexec/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func NewRootCommand() *cobra.Command {
command.AddCommand(NewAgentCommand())
command.AddCommand(NewEmissaryCommand())
command.AddCommand(NewInitCommand())
command.AddCommand(NewKillCommand())
command.AddCommand(NewResourceCommand())
command.AddCommand(NewWaitCommand())
command.AddCommand(NewDataCommand())
Expand Down
21 changes: 9 additions & 12 deletions cmd/argoexec/commands/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package commands

import (
"context"
"os/signal"
"syscall"
"time"

"github.com/argoproj/pkg/stats"
Expand Down Expand Up @@ -32,20 +30,19 @@ func waitContainer(ctx context.Context) error {
defer stats.LogStats()
stats.StartStatsTicker(5 * time.Minute)

// use a block to constrain the scope of ctx
{
// this allows us to gracefully shutdown, capturing artifacts
ctx, cancel := signal.NotifyContext(ctx, syscall.SIGTERM)
defer cancel()

// Wait for main container to complete
err := wfExecutor.Wait(ctx)
if err != nil {
defer func() {
if err := wfExecutor.KillSidecars(ctx); err != nil {
wfExecutor.AddError(err)
}
}()

// Wait for main container to complete
err := wfExecutor.Wait(ctx)
if err != nil {
wfExecutor.AddError(err)
}
// Capture output script result
err := wfExecutor.CaptureScriptResult(ctx)
err = wfExecutor.CaptureScriptResult(ctx)
if err != nil {
wfExecutor.AddError(err)
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/signals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ func (s *SignalsSuite) TestInjectedSidecar() {
WaitForWorkflow(fixtures.ToBeSucceeded, kill2xDuration)
}

func (s *SignalsSuite) TestSubProcess() {
func (s *SignalsSuite) TestInjectedSidecarKillAnnotation() {
s.Given().
Workflow("@testdata/subprocess-workflow.yaml").
Workflow("@testdata/sidecar-injected-kill-annotation-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow()
WaitForWorkflow(fixtures.ToBeSucceeded, kill2xDuration)
}

func TestSignalsSuite(t *testing.T) {
Expand Down
25 changes: 25 additions & 0 deletions test/e2e/testdata/sidecar-injected-kill-annotation-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: sidecar-injected-kill-annotation-
spec:
entrypoint: main
podMetadata:
annotations:
workflows.argoproj.io/kill-cmd-sidecar: '["sh", "-c", "kill -s%d -- -1"]'
podSpecPatch: |
terminationGracePeriodSeconds: 3
containers:
- name: wait
- name: main
- name: sidecar
image: argoproj/argosay:v1
command:
- sh
- -c
args:
- "sleep 999"
templates:
- name: main
container:
image: argoproj/argosay:v1
13 changes: 2 additions & 11 deletions workflow/signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package signal
import (
"encoding/json"
"fmt"
"path/filepath"
"strings"
"syscall"

Expand All @@ -16,16 +15,8 @@ import (

func SignalContainer(restConfig *rest.Config, pod *corev1.Pod, container string, s syscall.Signal) error {
command := []string{"/bin/sh", "-c", "kill -%d 1"}

// If the container has the /var/run/argo volume mounted, this it will have access to `argoexec`.
for _, c := range pod.Spec.Containers {
if c.Name == container {
for _, m := range c.VolumeMounts {
if m.MountPath == common.VarRunArgoPath {
command = []string{filepath.Join(common.VarRunArgoPath, "argoexec"), "kill", "%d", "1"}
}
}
}
if container == common.WaitContainerName {
command = []string{"/bin/sh", "-c", "kill -%d $(pidof argoexec)"}
}

if v, ok := pod.Annotations[common.AnnotationKeyKillCmd(container)]; ok {
Expand Down

0 comments on commit 5db53aa

Please sign in to comment.