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
Handle validation failures on startup more gracefully #1113
Comments
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jun 27, 2020
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. I've also added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. Fixes tomkerkhove#1113
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jun 27, 2020
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. I've also added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. Fixes tomkerkhove#1113
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jun 27, 2020
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. I've also added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. Fixes tomkerkhove#1113
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jun 28, 2020
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. Also: - Added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. - Updated the unhandled exception message to point people to raising an issue. - Altered the check to make sure the config folder is set so that it exits gracefully instead of ending up in the unhandled exception block. - Moved the logging about whether or not the configuration is valid from RuntimeValidator into the main method. It seemed more appropriate for the logging to be there since the main method now has logic for exiting if the config is invalid. Fixes tomkerkhove#1113
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jun 28, 2020
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. Also: - Added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. - Updated the unhandled exception message to point people to raising an issue. - Altered the check to make sure the config folder is set so that it exits gracefully instead of ending up in the unhandled exception block. - Moved the logging about whether or not the configuration is valid from RuntimeValidator into the main method. It seemed more appropriate for the logging to be there since the main method now has logic for exiting if the config is invalid. Fixes tomkerkhove#1113
Re-opening for resource discovery agent |
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jul 3, 2020
- Moved `ExitStatus` into the agents core and updated the discovery agent to use it. - Updated the unhandled exception message for the discovery agent to match the format of the scraper agent. - Added some additional validation to both agents to check that their required config files exist. This is to avoid us ending up in the unhandled exception block and directing users to create an issue. Fixes tomkerkhove#1113
adamconnelly
added a commit
to adamconnelly/promitor
that referenced
this issue
Jul 5, 2020
- Moved `ExitStatus` into the agents core and updated the discovery agent to use it. - Updated the unhandled exception message for the discovery agent to match the format of the scraper agent. - Added some additional validation to both agents to check that their required config files exist. This is to avoid us ending up in the unhandled exception block and directing users to create an issue. Fixes tomkerkhove#1113
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the moment Promitor relies on throwing a
ValidationFailedException
to crash the application if the configuration isn't valid. This isn't ideal because it adds noise to the console output, meaning you have to scroll back up past the stack trace to get to the validation error.Here's an example of the output you receive:
In this case the situation isn't really exceptional, in the sense that it's part of the normal lifecycle of the application, and we expect that validation can fail (which is why we're doing it in the first place!), so relying on an exception like this doesn't feel appropriate. The stack trace also doesn't add value to Promitor users since the validation already tells them what's wrong, and isn't necessary for developers since we know where the validation code lives, and we can see the step that failed from the error message.
Specification
The application should follow the following lifecycle:
We can use a similar approach to the one outlined here to achieve this: https://andrewlock.net/running-async-tasks-on-app-startup-in-asp-net-core-part-1/#4-manually-running-tasks-in-program-cs.
This will allow us to run validation, exiting with a non-zero exit code if validation fails.
Question
Currently validation continues even if a previous step has failed. Is this deliberate, and is it the behaviour we want?
The text was updated successfully, but these errors were encountered: