Skip to content

Commit

Permalink
Merge pull request #1248 from dgageot/fix-1247
Browse files Browse the repository at this point in the history
Fix jib errors on ctrl-c
  • Loading branch information
dgageot authored Nov 8, 2018
2 parents a8db96e + b7bf0cf commit b645a36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 8 additions & 1 deletion cmd/skaffold/skaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ limitations under the License.
package main

import (
"context"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app"
)

func main() {
if err := app.Run(); err != nil {
logrus.Fatal(err)
if errors.Cause(err) == context.Canceled {
logrus.Debugln(errors.Wrap(err, "ignore error since context is cancelled"))
} else {
logrus.Fatal(err)
}
}
}
7 changes: 1 addition & 6 deletions pkg/skaffold/jib/jib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ 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 {
logrus.Debugln(errors.Wrap(err, "ignore error since context is cancelled"))
return nil, nil
}

return nil, err
}

Expand Down

0 comments on commit b645a36

Please sign in to comment.