-
Notifications
You must be signed in to change notification settings - Fork 813
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
[Core] Utilize sys.exit in configcheck #3481
Conversation
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 fix makes a lot of sense, thanks!
I think the current behavior is actually a regression that was introduced way back in #1422.
I don't think exiting directly from the configcheck
option is great though, there might be other callers of this function that just want to check if the configs are valid without exiting the process if they're not.
The caller of configcheck
should use the returned value of the function and exit with that value if it makes sense to exit. Does that make sense?
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.
Getting better, added one comment on the current changes
agent.py
Outdated
@@ -602,8 +602,8 @@ def parent_func(): | |||
check.stop() | |||
|
|||
elif 'configcheck' == command or 'configtest' == command: | |||
configcheck() | |||
sd_configcheck(agentConfig) | |||
if configcheck() or sd_configcheck(agentConfig): |
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.
sd_configcheck
doesn't return anything so I don't think it makes sense to have it in the condition here. I'm not sure we could make that function return a sensible value that reflects the status of the service discovery confs...
So instead of this, I think we should simply make this code return the value that configcheck
returns. The part of the code under __main__
will then exit with the correct status code.
Thanks @nmuesch! Merged, this should be included in 5.17.0 |
Note: Please remember to review the Datadog Contribution Guidelines
if you have not yet done so.
What does this PR do?
Utilizes the sys.exit() function in the
configcheck
command utility. This allows the exit code to be determined based on whether or not the yaml configs are good/bad.Motivation
Customer Request. Now when running the one off config check script/command, you can utilize
$?
to determine if there are any bad yaml files.Previously, if the configcheck finished and printed that there were errors in the yaml files, the following command:
would output `0. Now this outputs 1, indicating there was a failure.
Testing Guidelines
An overview on testing
is available in our contribution guidelines.
Additional Notes
Anything else we should know when reviewing?