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

Support both for onPremise and onPrem within interal binaries #532

Closed
wants to merge 3 commits into from

Conversation

khanhntd
Copy link
Contributor

@khanhntd khanhntd commented Aug 2, 2022

Close #474

Description of the issue

Support both onPrem and onPremise for config translator due to breaking changes

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

For testing, building binaries from external repo and implement the changes:

  • On Mac (with CTL) - CTL only supports on Premise
sudo ./amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -s -c file:./config.json

Got Home directory: /var/root
I! Set home dir Linux: /var/root
I! SDKRegionWithCredsMap region:  us-west-2
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp
2022/08/02 14:15:18 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp ...
2022/08/02 14:15:18 I! Valid Json input schema.
  • On Mac (with Translator) - OnPrem
khanhntd@88665a0eaf54 amazon-cloudwatch-agent-pre-pkg % ./config-translator --input ./config.json --mode onPrem   
2022/08/02 14:05:54 Reading json config file path: ./config.json ...
Cannot access : lstat : no such file or directory 
2022/08/02 14:05:54 unable to scan config dir  with error: lstat : no such file or directory
2022/08/02 14:05:54 I! Valid Json input schema.
  • On Mac (with Translator) - OnPremise
khanhntd@88665a0eaf54 amazon-cloudwatch-agent-pre-pkg % ./config-translator --input ./config.json --mode onPremise
2022/08/02 14:06:03 Reading json config file path: ./config.json ...
Cannot access : lstat : no such file or directory 
2022/08/02 14:06:03 unable to scan config dir  with error: lstat : no such file or directory
2022/08/02 14:06:03 I! Valid Json input schema.
  • On Mac (with Translator) - Unexpected mode
khanhntd@88665a0eaf54 amazon-cloudwatch-agent-pre-pkg % ./config-translator --input ./config.json --mode onPremi
2022/08/02 14:05:58 Invalid mode onPremi. Valid mode values are ec2, onPrem and onPremise.
panic: Invalid mode onPremi. Valid mode values are ec2, onPrem and onPremise.

goroutine 1 [running]:
log.Panicf({0x162887b?, 0x7?}, {0xc00019fd50?, 0xc0003443c0?, 0x0?})

  • On Linux (similar test case to Mac)

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make linter

@codecov-commenter
Copy link

codecov-commenter commented Aug 2, 2022

Codecov Report

Merging #532 (9aa2859) into master (a809746) will decrease coverage by 0.26%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #532      +/-   ##
==========================================
- Coverage   57.03%   56.77%   -0.27%     
==========================================
  Files         373      374       +1     
  Lines       17665    17760      +95     
==========================================
+ Hits        10076    10083       +7     
- Misses       6999     7085      +86     
- Partials      590      592       +2     
Impacted Files Coverage Δ
cmd/config-translator/translator.go 0.00% <0.00%> (ø)
plugins/outputs/cloudwatch/cloudwatch.go 75.27% <0.00%> (-0.66%) ⬇️
translator/cmdutil/userutil_darwin.go 10.52% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.

@khanhntd khanhntd marked this pull request as ready for review August 5, 2022 15:07
@khanhntd khanhntd requested a review from a team as a code owner August 5, 2022 15:07
@@ -106,7 +106,8 @@ amazon-cloudwatch-agent-config-wizard: copy-version-file
$(LINUX_AMD64_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(LINUX_ARM64_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(WIN_BUILD)/amazon-cloudwatch-agent-config-wizard.exe github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(DARWIN_BUILD)/amazon-cloudwatch-agent-config-wizard github.com/aws/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent-config-wizard
$(DARW
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a visual bug?

Copy link
Contributor Author

@khanhntd khanhntd Aug 5, 2022

Choose a reason for hiding this comment

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

I fixed that in old commit and its not shown for me with newest commit https://github.com/aws/amazon-cloudwatch-agent/pull/532/files. So yes might be a visual bug

@khanhntd
Copy link
Contributor Author

khanhntd commented Aug 5, 2022

Duplicate of #543

@khanhntd khanhntd marked this as a duplicate of #543 Aug 5, 2022
@khanhntd khanhntd closed this Aug 5, 2022
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.

ctl script should handle "onPrem" as well as "onPremise"
3 participants