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

Improve log aggregator host/port validation #14333

Draft
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

relrod
Copy link
Member

@relrod relrod commented Aug 11, 2023

Don't merge yet - I want to add more tests.

SUMMARY
  • Simplify validation functions for logging settings

  • Abstract some host/port parsing logic out in utils.external_logging so the validation function can use it as settings are updated

  • Never crash-loop if somehow http logging settings are invalid, just log errors (to the console!) and write a default /dev/null syslog config.

  • Add a bunch of new test cases for various scenarios (most of them pass before the changes, but we throw some new errors now when validation fails).

Fixes #13823
Refs #13829

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

- Simplify validation functions for logging settings

- Abstract some host/port parsing logic out in utils.external_settings
  so the validation function can use it as settings are updated

- Never crash-loop if somehow http logging settings are invalid, just
  log errors (to the console!) and write a default /dev/null syslog
  config.

- Add a bunch of new test cases for various scenarios (most of them pass
  before the changes, but we throw some new errors now when validation
  fails).

Fixes ansible#13823
Refs ansible#13829

Signed-off-by: Rick Elrod <[email protected]>
# It would be really nice to check that if a port number is set here, then it's not also set in LOG_AGGREGATOR_PORT.
# But that would be a breaking change vs. silently preferring the port number in LOG_AGGREGATOR_HOST.
try:
host, port, parsed = validate_http_host_port(new_host, throw=True)
Copy link
Member

Choose a reason for hiding this comment

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

nice to reuse the validation method in both places.

'LOG_AGGREGATOR_TYPE',
'LOG_AGGREGATOR_PROTOCOL',
)
if not serializer.instance or not all(hasattr(serializer.instance, attr) for attr in needed_attrs) or not attrs.get('LOG_AGGREGATOR_ENABLED', False):
Copy link
Member

Choose a reason for hiding this comment

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

This is messing me up. I'm trying to manually run your test cases, but essentially all cases are bailing early on this line and not throwing the 400 errors because of that.

Still not sure to do with this information, but that's the big thing for verifying the functionality of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misconfigured LOG_AGGREGATOR_URL can cause dispatcher to go into a crash loop.
2 participants