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

[master] Fix options parsing of highstate returner #66828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Guillaume-COEUGNET
Copy link

@Guillaume-COEUGNET Guillaume-COEUGNET commented Aug 22, 2024

What does this PR do?

Fix Issue #66816

What issues does this PR fix or reference?

Fixes #66816

Previous Behavior

Highstate returner doesn't take in configuration of some "report_" options

New Behavior

Now the returner use configuration of options report_failures, report_changes and report_everything and send report accordingly.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@Guillaume-COEUGNET Guillaume-COEUGNET requested a review from a team as a code owner August 22, 2024 13:02
Copy link

welcome bot commented Aug 22, 2024

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title Fix options parsing of highstate returner [master] Fix options parsing of highstate returner Aug 22, 2024
@@ -164,7 +164,7 @@ def _options_browser(cfg, ret_config, defaults, virtualname, options):
# default place for the option in the config
value = _fetch_option(cfg, ret_config, virtualname, options[option])

if value:
if value != "":
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect value is not None also should be in this condition, but I am not sure what the the previous condition was trying to achieve.

Copy link
Author

@Guillaume-COEUGNET Guillaume-COEUGNET Aug 23, 2024

Choose a reason for hiding this comment

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

The previous condition try to avoid parameters without value and then, not record them in the dict. But the previous code catchs parameters with "False" value which souldn't be, causing thoose parameters to be excluded of the dict. value is not None could be an alternative, not tested it.

Copy link
Contributor

Choose a reason for hiding this comment

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

value is not None would miss value = "". The original code if value would evaluate True for both scenarios(None and ""). Not sure what this code is actually fixing.

Copy link
Author

Choose a reason for hiding this comment

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

Hello twangboy,

Have you read the issue #66816 ?
"if value:" doesn't work for any configuration directives that is equal to False, like this

highstate.report_failures: True
highstate.report_changes: False
highstate.report_everything: False

Which gives this logs :

[DEBUG ] highstate setup {'report_format': 'html', 'report_delivery': 'smtp', 'smtp_sender': '[email protected]', 'smtp_recipients': '[email protected]', 'smtp_failure_subject': 'failure minion {id} on host {host}', 'smtp_success_subject': 'succes minion {id} on host {host}', 'smtp_server': 'smtpunix.it.noname.fr'}

Fixing code with "if value != """ gives this log :

[DEBUG ] highstate setup {'report_everything': False, 'report_changes': False, 'report_failures': True, 'report_format': 'html', 'report_delivery': 'smtp', 'smtp_sender': '[email protected]', 'smtp_recipients': '[email protected]', 'smtp_failure_subject': 'failure minion {id} on host {host}', 'smtp_success_subject': 'succes minion {id} on host {host}', 'smtp_server': 'smtpunix.it.noname.fr'}

This proceed reports to be send as desired.

Regards.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, so we're just checking if value is set to either True or False. Do we need to handle None here?

This will also need a changelog and some tests. You can you caplog to test debug output.

@@ -164,7 +164,7 @@ def _options_browser(cfg, ret_config, defaults, virtualname, options):
# default place for the option in the config
value = _fetch_option(cfg, ret_config, virtualname, options[option])

if value:
if value != "":
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, so we're just checking if value is set to either True or False. Do we need to handle None here?

This will also need a changelog and some tests. You can you caplog to test debug output.

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.

[BUG] Highstate Returner doesn't take in consideration "report_failure" configuration
3 participants