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

Return a non-zero status code for failed plugins #463

Merged
merged 1 commit into from
Jul 9, 2018
Merged
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
11 changes: 11 additions & 0 deletions cmd/sonobuoy/app/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,21 @@ func getStatus(cmd *cobra.Command, args []string) {
} else {
err = printSummary(os.Stdout, status)
}

if err != nil {
errlog.LogError(err)
os.Exit(1)
}
os.Exit(exitCode(status))
}

func exitCode(status *aggregation.Status) int {
switch status.Status {
case aggregation.FailedStatus:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not an error on GetStatus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because it's not an error getting the status -- the error is on the plugin and is reported through the status.

Copy link
Contributor

Choose a reason for hiding this comment

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

k, that name aggregation.FailedStatus is super generic.

Do you have an example of this failure w/exit 1?

What does it look like to the user?

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 don't have an example, but it will look like this (hand crafted output):

test salazar:sonobuoy cha$ sonobuoy status
PLUGIN		STATUS		COUNT
e2e		complete	1
systemd_logs	failed	1

Sonobuoy has failed. You can see what happened with `sonobuoy logs`.

test salazar:sonobuoy cha$ echo $?
1

return 1
default:
return 0
}
}

func humanReadableStatus(str string) string {
Expand Down