Skip to content

Commit

Permalink
fix: Correct SIGTERM handling. Fixes #argoproj#10518 argoproj#10337 a…
Browse files Browse the repository at this point in the history
…rgoproj#10033 argoproj#10490

Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Feb 12, 2023
1 parent 9cb3fc6 commit 3a09875
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions cmd/argo/commands/common/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func printNode(w *tabwriter.Writer, node wfv1.NodeStatus, wfName, nodePrefix str
// boundaryNode
func (nodeInfo *boundaryNode) renderNodes(w *tabwriter.Writer, wf *wfv1.Workflow, depth int, nodePrefix string, childPrefix string, getArgs GetFlags) {
filtered, childIndent := filterNode(nodeInfo.getNodeStatus(wf), getArgs)
println("ALEX", filtered)
if !filtered {
version := util.GetWorkflowPodNameVersion(wf)
printNode(w, nodeInfo.getNodeStatus(wf), wf.ObjectMeta.Name, nodePrefix, getArgs, version)
Expand Down
21 changes: 6 additions & 15 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,13 @@ func waitContainer(ctx context.Context) error {
defer stats.LogStats()
stats.StartStatsTicker(5 * time.Minute)

// use a function to constrain the scope of ctx
func() {
// 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 {
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
7 changes: 6 additions & 1 deletion cmd/argoexec/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package main

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

"github.com/argoproj/argo-workflows/v3/util/errors"

Expand All @@ -13,7 +16,9 @@ import (
)

func main() {
err := commands.NewRootCommand().Execute()
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM)
defer stop()
err := commands.NewRootCommand().ExecuteContext(ctx)
if err != nil {
if exitError, ok := err.(errors.Exited); ok {
if exitError.ExitCode() >= 0 {
Expand Down

0 comments on commit 3a09875

Please sign in to comment.