From 84aa21aeffb9542155331321f3371a63c391b058 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 7 Nov 2018 11:41:46 +0100 Subject: [PATCH 1/2] Ignore error if context was cancelled Signed-off-by: David Gageot --- cmd/skaffold/skaffold.go | 7 ++++++- pkg/skaffold/jib/jib.go | 7 +------ pkg/skaffold/runner/runner.go | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/skaffold/skaffold.go b/cmd/skaffold/skaffold.go index 51bd620ba92..1f2fb60ff32 100644 --- a/cmd/skaffold/skaffold.go +++ b/cmd/skaffold/skaffold.go @@ -17,6 +17,9 @@ limitations under the License. package main import ( + "context" + + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/GoogleContainerTools/skaffold/cmd/skaffold/app" @@ -24,6 +27,8 @@ import ( func main() { if err := app.Run(); err != nil { - logrus.Fatal(err) + if errors.Cause(err) != context.Canceled { + logrus.Fatal(err) + } } } diff --git a/pkg/skaffold/jib/jib.go b/pkg/skaffold/jib/jib.go index 2c70a2b848c..7c8746117ff 100644 --- a/pkg/skaffold/jib/jib.go +++ b/pkg/skaffold/jib/jib.go @@ -17,11 +17,10 @@ limitations under the License. package jib import ( + "os" "os/exec" "sort" - "os" - "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" "github.com/karrick/godirwalk" "github.com/pkg/errors" @@ -31,10 +30,6 @@ import ( func getDependencies(cmd *exec.Cmd) ([]string, error) { stdout, err := util.RunCmdOut(cmd) if err != nil { - // if terminated because of ^C then act as if all is well - if util.IsTerminatedError(err) { - return nil, nil - } return nil, err } diff --git a/pkg/skaffold/runner/runner.go b/pkg/skaffold/runner/runner.go index da05aac9f5f..0bf2ee7c396 100644 --- a/pkg/skaffold/runner/runner.go +++ b/pkg/skaffold/runner/runner.go @@ -465,6 +465,12 @@ func DependenciesForArtifact(ctx context.Context, a *latest.Artifact) ([]string, } if err != nil { + // if the context was cancelled act as if all is well + // TODO(dgageot): this should be even higher in the call chain. + if ctx.Err() == context.Canceled { + return nil, nil + } + return nil, err } From b7bf0cff000e696436450595defe3a567da1ac70 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 8 Nov 2018 19:10:05 +0100 Subject: [PATCH 2/2] Add debug logs Signed-off-by: David Gageot --- cmd/skaffold/skaffold.go | 4 +++- pkg/skaffold/runner/runner.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/skaffold/skaffold.go b/cmd/skaffold/skaffold.go index 1f2fb60ff32..27962edab65 100644 --- a/cmd/skaffold/skaffold.go +++ b/cmd/skaffold/skaffold.go @@ -27,7 +27,9 @@ import ( func main() { if err := app.Run(); err != nil { - if errors.Cause(err) != context.Canceled { + if errors.Cause(err) == context.Canceled { + logrus.Debugln(errors.Wrap(err, "ignore error since context is cancelled")) + } else { logrus.Fatal(err) } } diff --git a/pkg/skaffold/runner/runner.go b/pkg/skaffold/runner/runner.go index 0bf2ee7c396..3c74320a425 100644 --- a/pkg/skaffold/runner/runner.go +++ b/pkg/skaffold/runner/runner.go @@ -468,6 +468,7 @@ func DependenciesForArtifact(ctx context.Context, a *latest.Artifact) ([]string, // if the context was cancelled act as if all is well // TODO(dgageot): this should be even higher in the call chain. if ctx.Err() == context.Canceled { + logrus.Debugln(errors.Wrap(err, "ignore error since context is cancelled")) return nil, nil }