-
Notifications
You must be signed in to change notification settings - Fork 86
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
Surface Workload and Jinja Template Errors to Console and Provide Common Solutions #448
Surface Workload and Jinja Template Errors to Console and Provide Common Solutions #448
Conversation
Signed-off-by: Ian Hoang <[email protected]>
Signed-off-by: Ian Hoang <[email protected]>
Put this together quickly but am open to refactoring this to make it cleaner. Would prefer if we store the error handling messages elsewhere instead of within the |
Signed-off-by: Ian Hoang <[email protected]>
Signed-off-by: Ian Hoang <[email protected]>
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.
This is a really helpful PR, that many users will appreciate!
except jinja2.exceptions.TemplateNotFound: | ||
self.logger.exception("Could not load [%s]", workload_spec_file) | ||
raise exceptions.SystemSetupError("Workload {} does not exist".format(workload_name)) | ||
|
||
except jinja2.exceptions.TemplateSyntaxError as e: |
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.
This is a really good improvement. The implementation is fine for now, but moving the processing to a separate function with a map of error string patterns to suggestions would be helpful. This could be in a separate module and can be updated if the Jinja2 parser changes.
msg = "Could not load '{}'. The complete workload has been written to '{}' for diagnosis. \n\n".format( | ||
workload_spec_file, tmp.name) | ||
console_message = f"Suggestion: Verify that [{workload_name}] workload has correctly formatted JSON files and " + \ | ||
"Jinja Templates. For Jinja2 errors, consider using a live Jinja2 parser. " + \ | ||
f"See common workload formatting errors:{WorkloadFileReader.COMMON_WORKLOAD_FORMAT_ERRORS}" | ||
msg += console_message |
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.
Might be helpful to consolidate the repetition into a function, so that possible future changes don't need to made in two places.
Signed-off-by: Ian Hoang <[email protected]>
Description
Users have often made changes to OSB workloads and come across vague and unclear errors. Instead of showing them what the error is or providing them common issues and suggestions on how to fix them, the console wouuld show the following:
These files are usually empty and not useful.
This PR adds better error handling when OSB attempts to render workload files and Jinja templates. Users do not have to dig into the OSB logs anymore for workload and jinja template errors or guess as to what went wrong. These changes now surface the error to the console and highlight common issues and solutions.
Issues Resolved
#447
Testing
Recreated common errors in
workload.json
,operations/default.json
, andtest_procedures/default.json
. Ran the tests and encountered more descriptive error handling that either provides the place to fix or recommendations of common issues and solutions.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.