[VC-35738] Bubble up the errors from sub-commands and handle errors centrally instead of using log.Fatal at multiple sites#599
Merged
wallrj merged 5 commits intoVC-35738/featurefrom Nov 5, 2024
Conversation
wallrj
commented
Oct 30, 2024
| // Usage information is still available on stdout with the `-h` and `--help` | ||
| // flags. | ||
| SilenceErrors: true, | ||
| SilenceUsage: true, |
Contributor
Author
There was a problem hiding this comment.
As suggested by @maelvls in #593 (comment)
This was referenced Oct 30, 2024
4438c98 to
817f07c
Compare
54dc42e to
864edd3
Compare
35d6638 to
23579e7
Compare
23579e7 to
708b1d7
Compare
b4ee1ac to
704847d
Compare
Signed-off-by: Richard Wall <richard.wall@venafi.com>
…up the stderr output Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
704847d to
045142c
Compare
maelvls
approved these changes
Nov 5, 2024
Member
maelvls
left a comment
There was a problem hiding this comment.
It seems all good to me. I haven't tested this manually, but I trust the output that you gave.
wallrj
commented
Nov 6, 2024
| err = multierror.Append( | ||
| err, | ||
| fmt.Errorf("failed to wait for controller-runtime component to stop: %v", groupErr), | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
This caused a bug.
The group error is discarded, because I was assigning to the err variable assuming that it was the returned error, but it's not.
Member
|
For context, we have done the same thing in Firefly: https://gitlab.com/venafi/vaas/applications/tls-protect/dmi/cli/firefly-ca/-/merge_requests/426 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small part of a larger effort to allow the agent to use structured logging.
This will make it easier for platform administrators to parse the logs and to distinguish errors from info messages.
It also is a small part of an effort to use contextual logging instead of the legacy
logmodule.This will make it easier to test the log output of our code in unit tests.
The existing code uses
log.Fatalat the site of various errors to both print the error and to exit the process with code 1.Instead the errors should be returned and bubbled back to the root command, which makes it easier to handle the errors in a consistent fashion and makes it easier to test the code that had previously caused the process to exit.
$ git grep -i '\.fatal' | grep -v 't\.Fatal'Example output: