-
Notifications
You must be signed in to change notification settings - Fork 8
Feat(Block on missing config) #42
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
Conversation
|
Is this fully ready? At the interface PR stage, this should be marked as draft please |
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.
license-eye has checked 283 files.
| Valid | Invalid | Ignored | Fixed |
|---|---|---|---|
| 155 | 1 | 127 | 0 |
Click to see the invalid file list
- tests/unit/general/conftest.py
Use this command to fix any missing license headers
```bash
docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix
</details>
jdkandersson
left a comment
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.
Please remember to update the charmcraft docs
This PR is related to 12 Factor [Block on missing required config PR](canonical/paas-charm#42) ## Rationale Some applications require certain config options to run and would crash if these options are not provided. To prevent this, we need to add an optional field to the config options and block the charm if a config option marked as non-optional has not been provided with a message that explains which config options are missing. To stay backward compatible the default value for the optional field will be true. Since it doesn’t make sense for config options that are non-optional to have a default value, charmcraft will look for this condition at pack time and error out. ## Extension Changes Adds a check for non-optional options with default values and throws `ExtensionError` when found. Adds documentation about the non-optional options. Reviewers: @jdkandersson @javierdelapuente @erinecon
Overview
Some applications require certain configuration options to function correctly. With this PR when a non-optional config option is missing, the charm will go into the blocked state with a message telling which config options are missing.
Rationale
Some applications require certain config options to run and would crash if these options are not provided. To prevent this, we need to add an optional field to the config options and block the charm if a config option marked as non-optional has not been provided with a message that explains which config options are missing.
To stay backward compatible the default value for the optional field will be true.
Since it doesn’t make sense for config options that are non-optional to have a default value, charmcraft will look for this condition at pack time and error out.
Module Changes
2 new functions in
paas_charm.charm_state.pyare added to create theAppConfigclass from the list of configuration options:app_config_factory_create_configuration_attributepaas_charm.utils.build_validation_error_messagefunction is changed. Now it returns a tuple of 2 strings.The tuple consists of:
messages. Best fit for printing error logs.
A new function in
paas_charm.utils.py:is_user_defined_config: This function checks whether a config option is user-defined.Add a new folder to unit tests to check functions not affected by the framework.
Add a new folder to integration tests to check functionality in every framework by parametrizing the framework. This way we only need to write 1 function to test functionality in every framework.
Checklist
src-docsurgent,trivial,complex)