Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add retry when kill container #7404

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion cmd/argoexec/commands/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"github.com/argoproj/pkg/stats"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/wait"

errorsutil "github.com/argoproj/argo-workflows/v3/util/errors"
"github.com/argoproj/argo-workflows/v3/workflow/executor"
)

func NewWaitCommand() *cobra.Command {
Expand All @@ -31,7 +35,18 @@ func waitContainer(ctx context.Context) error {
stats.StartStatsTicker(5 * time.Minute)

defer func() {
if err := wfExecutor.KillSidecars(ctx); err != nil {
// Killing sidecar containers
err := wait.ExponentialBackoff(executor.ExecutorRetry, func() (bool, error) {
henrywangx marked this conversation as resolved.
Show resolved Hide resolved
err := wfExecutor.KillSidecars(ctx)
if err == nil {
return true, nil
}
if errorsutil.IsTransientErr(err) {
return false, nil
}
return false, err
})
if err != nil {
wfExecutor.AddError(err)
}
}()
Expand Down
17 changes: 12 additions & 5 deletions workflow/executor/k8sapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
errorsutil "github.com/argoproj/argo-workflows/v3/util/errors"
waitutil "github.com/argoproj/argo-workflows/v3/util/wait"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/executor"
execcommon "github.com/argoproj/argo-workflows/v3/workflow/executor/common"
)

Expand Down Expand Up @@ -110,11 +111,17 @@ func (c *k8sAPIClient) GetContainerStatuses(ctx context.Context) (*corev1.Pod, [

func (c *k8sAPIClient) KillContainer(pod *corev1.Pod, container *corev1.ContainerStatus, sig syscall.Signal) error {
command := []string{"/bin/sh", "-c", fmt.Sprintf("kill -%d 1", sig)}
exec, err := common.ExecPodContainer(c.config, c.namespace, c.podName, container.Name, true, true, command...)
if err != nil {
return err
}
_, _, err = common.GetExecutorOutput(exec)
err := wait.ExponentialBackoff(executor.ExecutorRetry, func() (bool, error) {
exec, err := common.ExecPodContainer(c.config, c.namespace, c.podName, container.Name, true, true, command...)
if err != nil {
return false, nil
}
_, _, err = common.GetExecutorOutput(exec)
if err != nil {
return false, err
}
Comment on lines +120 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably only want to retry for transient errors?

return true, nil
})
return err
}

Expand Down