From 074e47d9c061db34201d5041afffc65e23f8c3af Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 24 Feb 2021 18:48:55 -0800 Subject: [PATCH] logs: clean up logs for canceled tasks Signed-off-by: Andrea Luzzardi --- dagger/env.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dagger/env.go b/dagger/env.go index 6c3cd022..333fd468 100644 --- a/dagger/env.go +++ b/dagger/env.go @@ -3,6 +3,7 @@ package dagger import ( "context" "fmt" + "strings" "time" "cuelang.org/go/cue" @@ -297,18 +298,26 @@ func newPipelineTaskFunc(ctx context.Context, inst *cue.Instance, s Solver) cuef p := NewPipeline(t.Path().String(), s, NewFillable(t)) err := p.Do(ctx, v) if err != nil { + // FIXME: this should use errdefs.IsCanceled(err) + if strings.Contains(err.Error(), "context canceled") { + lg. + Error(). + Dur("duration", time.Since(start)). + Msg("canceled") + return err + } lg. Error(). Dur("duration", time.Since(start)). Err(err). Msg("failed") - } else { - lg. - Info(). - Dur("duration", time.Since(start)). - Msg("completed") + return err } - return err + lg. + Info(). + Dur("duration", time.Since(start)). + Msg("completed") + return nil }), nil } }