-
Notifications
You must be signed in to change notification settings - Fork 213
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
fetch-config should error if the input file is not valid JSON #404
Comments
If you run sudo /opt/aws/amazon-cloudwatch-agent/bin/config-translator -input /opt/aws/amazon-cloudwatch-agent/var/cwagent-config.json -output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
echo $? What does it output for the exit code? I'm curious if the ${command} || return which I think kicks out of the function if there's a non-zero exit code there. |
Actually just confirmed it for myself:
I think that the change would be straightforward, however I think that the existing fail-through behavior complicates things for existing users because it exposes any invalid configuration that they are currently using by failing the agent potentially - although if their configuration is invalid, then they wouldn't see any of the metrics/logs that they want and they'd ideally fix that themselves anyway |
Here is the same
|
Ahh I see. I missed that config - and also didn't think it would have such a big change to the exit code or behavior. |
I think at least the I understand that "fixing" this issue with a non-zero exit code may be a non backward compatible change for those with invalid configs (hopefully those would be very few), but it will help most people to get correct configurations working. Another alternative would be to add some option to |
I think that adding an optional flag to denote that the control script should fail on invalid configurations, as well as including a more prominent error on failure to translate are a good compromise |
@SaxyPandaBear , @khanhntd . It's my understanding from #412 that the plan to fix this issue with a better log statements rather than an actual error, so I guess this should be closed too as "WON'T DO", or? |
@ecerulm yeah will be closing out this issue. I think I misjudged just how tightly coupled everything is |
Currently the following command:
will overwrite
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
even if the input JSON file is not valid JSON.It will print out No json config files found, use the default one
But the exit value is still 0 (indicating no error). My proposal is that if the input file is invalid it should error (non zero exit code) and refuse to overwrite the TOML file.. Otherwise it's very easy to miss that the configuration was incorrectly updated.
Full output:
The text was updated successfully, but these errors were encountered: