-
Notifications
You must be signed in to change notification settings - Fork 158
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: Return error exit code when collectors fail #527
Conversation
d647824
to
a5f43d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this 👍
The main thing is the desired error behaviour -
I believe that when there's a failure with one of the enabled collectors, we should always exit with an error, irrespective of the config.ExitError
option. That option/flag is meant to configure whether there should be an error when issues are found - i.e. kubent
operates successfully, but has found some deprecated resources. If we fail to operate successfully, we should always exit with error.
So in this case, I would error always, irrespective of that flag.
Some minor comments in the code on implementation and the logging bit.
Plus can we cover this with a test? Perhaps it could be another one in
kube-no-trouble/cmd/kubent/main_test.go
Line 104 in f6ebd85
func TestMainExitCodes(t *testing.T) { |
feaff6d
to
61a6fc0
Compare
@stepanstipl ok, reviewed all comments and updated should be more go like apologies. |
3f4e824
to
ac6a888
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good, just 2 minor nitpicks in code.
But I realised one thing - when looking at the tests. I think the test is good, but I was also thinking it might be good to cover the two scenarios from #450:
a) Nonexisting/wrong cluster endpoint
b) Malformed kubeconfig
And I realised that we probably only cover half of the issue. The 2nd b) failure does not seem to come from getCollectors
, but rather from the initCollectors
:
initCollectors := initCollectors(config)
Happy to leave the init bit for another PR, and we probably should for the sake of getting this in, but just to be aware we're fixing just half of the scenarios from #450.
ac6a888
to
0e07b00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dark0dave, you want to get this in?
I'm happy with the code 👍, there's just one test failing (I believe it's just the return code 200 -> 100
). Cheers 🎉
0e07b00
to
df877c1
Compare
@stepanstipl should be all good now |
df877c1
to
06c2cce
Compare
…og level for silent resource failures Signed-off-by: dark0dave <[email protected]>
06c2cce
to
b10c776
Compare
Error, errors out properly closes #450 and increased log level for silent resource failures