-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
base: devel
Are you sure you want to change the base?
Conversation
- 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]>
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) |
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.
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): |
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 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.
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
COMPONENT NAME