From a6aca18e1d6f73022263628c6e64e317a4d1b326 Mon Sep 17 00:00:00 2001 From: wangxiang Date: Thu, 1 Dec 2022 23:11:11 +0800 Subject: [PATCH] fix (argo wait): use functions to constrain ctx instead of blocks (#10140) Signed-off-by: scott --- cmd/argoexec/commands/wait.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/argoexec/commands/wait.go b/cmd/argoexec/commands/wait.go index c3b66e39e4fa..170f7e1521ee 100644 --- a/cmd/argoexec/commands/wait.go +++ b/cmd/argoexec/commands/wait.go @@ -32,8 +32,8 @@ func waitContainer(ctx context.Context) error { defer stats.LogStats() stats.StartStatsTicker(5 * time.Minute) - // use a block to constrain the scope of ctx - { + // 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() @@ -43,7 +43,7 @@ func waitContainer(ctx context.Context) error { if err != nil { wfExecutor.AddError(err) } - } + }() // Capture output script result err := wfExecutor.CaptureScriptResult(ctx) if err != nil {