Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jib errors on ctrl-c #1248

Merged
merged 2 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will mask all errors. Perhaps you could log the error at a DEBUG level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea is to not show annoying errors when the user presses ctrl-c. No matter what the error is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I suggested DEBUG :-) Just in case those errors are due to something other than SIGTERM/KILL. Anyways, it's not a blocked from me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to add debug logs

logrus.Debugln(errors.Wrap(err, "ignore error since context is cancelled"))
return nil, nil
}

return nil, err
}

Expand Down