Skip to content
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

thar-be-settings: log a render error when running in --all mode #427

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

zmrow
Copy link
Contributor

@zmrow zmrow commented Oct 17, 2019

When running in --all mode, thar-be-settings (intentionally) does not fail
when a template fails to render. This commit logs a message
with the appropriate details in the event of a failure.

Issue #, if available:
Fixes #412

Description of changes:

  • Add match statement to catch and log the Err() case.

Testing done:

Run thar-be-settings with a setting passed on the command line:

bash-5.0# thar-be-settings <<< '["settings.hostname"]'
Oct 17 16:18:29.582  INFO thar_be_settings: thar-be-settings started
Oct 17 16:18:29.584  INFO thar_be_settings: Parsing stdin for updated settings
Oct 17 16:18:29.586  INFO thar_be_settings: Requesting affected services for settings: {"settings.hostname"}
Oct 17 16:18:29.592  INFO thar_be_settings: Requesting configuration file data for affected services
Oct 17 16:18:29.597  INFO thar_be_settings: Rendering config files...
Oct 17 16:18:29.599  INFO thar_be_settings: Writing config files to disk...
Oct 17 16:18:29.600  INFO thar_be_settings: Restarting affected services...

Run thar-be-settings --all on a system where a few kubernetes settings don't exist:

bash-5.0# thar-be-settings --all
Oct 17 16:18:35.319  INFO thar_be_settings: thar-be-settings started
Oct 17 16:18:35.320  INFO thar_be_settings: Requesting configuration file data for affected services
Oct 17 16:18:35.329  INFO thar_be_settings: Rendering config files...
Oct 17 16:18:35.331  INFO thar_be_settings::config: Unable to render template 'kubernetes-ca-crt': RenderError { desc: "TemplateHelperError :: InvalidTemplateValue", template_name: Some("kubernetes-ca-crt"), line_no: Some(1), column_no: Some(1), cause: Some(InvalidTemplateValue { expected:}...SNIP...
Oct 17 16:18:35.336  INFO thar_be_settings::config: Unable to render template 'kubelet-kubeconfig': RenderError { desc: "Variable \"settings.kubernetes.api-server\" not found in strict mode.", template_name: Some("kubelet-kubeconfig"), line_no: Some(7), column_no: Some(14), cause: None }  
Oct 17 16:18:35.341  INFO thar_be_settings: Writing config files to disk...
Oct 17 16:18:35.342  INFO thar_be_settings: Restarting all services...

bash-5.0# echo $?
0

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When running in `--all` mode, thar-be-settings does not fail
when a template fails to render. This commit logs a message
with the appropriate details in the event of a failure.
@zmrow
Copy link
Contributor Author

zmrow commented Oct 17, 2019

Updated per @tjkirch comments

Copy link
Contributor

@etungsten etungsten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎃

@zmrow zmrow merged commit f231633 into develop Oct 17, 2019
@zmrow zmrow deleted the tbs-log-render-err branch October 17, 2019 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

thar-be-settings: errors not logged in --all mode
3 participants