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

Fix: don't overwrite .env file #2261

Merged
merged 14 commits into from
Aug 11, 2023
Merged

Fix: don't overwrite .env file #2261

merged 14 commits into from
Aug 11, 2023

Conversation

rapphil
Copy link
Member

@rapphil rapphil commented Aug 9, 2023

Description: Do not overwrite the .env file in case ctl commands are executed. This is specially important if extra environment variables are passed in the .env file

Link to tracking Issue: #2243

Testing: Manual

(23-08-09 17:05:54) <130> [~/workplace/aws-otel-collector]
 % echo 'EXTRA_ENV2="foo"' | sudo tee -a  /opt/aws/aws-otel-collector/etc/.env
EXTRA_ENV2="foo"

(23-08-09 17:06:03) <0> [~/workplace/aws-otel-collector]
 % sudo cat /opt/aws/aws-otel-collector/etc/.env
config="--config http://example123.com"
EXTRA_ENV="foo"
EXTRA_ENV2="foo"

(23-08-09 17:06:07) <0> [~/workplace/aws-otel-collector]
 % sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a start -c http://example.com
Redirecting to /bin/systemctl restart aws-otel-collector.service

(23-08-09 17:06:16) <0> [~/workplace/aws-otel-collector]
 % sudo cat /opt/aws/aws-otel-collector/etc/.env
config="--config http://example.com"
EXTRA_ENV="foo"
EXTRA_ENV2="foo"

(23-08-09 17:06:18) <0> [~/workplace/aws-otel-collector]
 % sudo /opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl -a start -c /opt/aws/aws-otel-collector/var/.config.yaml
Redirecting to /bin/systemctl restart aws-otel-collector.service

(23-08-09 17:06:25) <0> [~/workplace/aws-otel-collector]
 % sudo cat /opt/aws/aws-otel-collector/etc/.env
config="--config /opt/aws/aws-otel-collector/etc/config.yaml"
EXTRA_ENV="foo"
EXTRA_ENV2="foo"

New tests were also added to validate the regression. I'm adding to both the CI and PR build since this test is very cheap to execute and does not require any special permissions.

Documentation:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rapphil rapphil requested a review from a team as a code owner August 9, 2023 17:15
Do not overwrite the .env file in case ctl commands are executed.
This is specially important if extra environment variables are passed in the .env file

Signed-off-by: Raphael Silva <rapphil@gmail.com>
@@ -253,6 +253,27 @@ jobs:
ARCH=amd64 DEST=build/packages/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 DEST=build/packages/debian/arm64 tools/packaging/debian/create_deb.sh

test-control-stript:
Copy link
Member Author

Choose a reason for hiding this comment

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

Using PR-build for now to test that this works.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to leave this permanently since these tests are very cheap to execute.

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
@@ -46,15 +46,15 @@ cp LICENSE "${AOC_ROOT}/opt/aws/aws-otel-collector/"
cp VERSION "${AOC_ROOT}/opt/aws/aws-otel-collector/bin/"
cp "build/linux/${ARCH}/aoc" "${AOC_ROOT}/opt/aws/aws-otel-collector/bin/aws-otel-collector"
cp tools/ctl/linux/aws-otel-collector-ctl.sh "${AOC_ROOT}/opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl"
cp config.yaml "${AOC_ROOT}/opt/aws/aws-otel-collector/etc"
# default configuration
Copy link
Member Author

Choose a reason for hiding this comment

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

adding this to this pr since this is a one liner.

This change will make the .deb file in parity with the RPM file and how the control script works.

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
@bryan-aguilar bryan-aguilar merged commit 3d239c5 into main Aug 11, 2023
27 checks passed
@bryan-aguilar bryan-aguilar deleted the rapphil-dont-overwrite-env branch August 11, 2023 17:20
bryan-aguilar added a commit that referenced this pull request Aug 12, 2023
* Fix: don't overwrite .env file (#2261)

* Fix: don't overwrite .env file

Do not overwrite the .env file in case ctl commands are executed.
This is specially important if extra environment variables are passed in the .env file

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add tests for control script

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix typo in github workflow

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix shell linting errors

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update .github/workflows/PR-build.yml

* Make debian aligned with RPM

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* properly install collector deb

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Use dpkg to install collector

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Properly use cache

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Move control script tests to the CI

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add the pr-build tests back

Signed-off-by: Raphael Silva <rapphil@gmail.com>

---------

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com>

* Fix control script to avoid sed special characters

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix typo in tests

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update release notes

Signed-off-by: Raphael Silva <rapphil@gmail.com>

---------

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com>
bryan-aguilar added a commit that referenced this pull request Aug 12, 2023
* bump version to v0.32.0

* Add windows version update

* Port fix of ctl script to v0.32.0 release (#2269)

* Fix: don't overwrite .env file (#2261)

* Fix: don't overwrite .env file

Do not overwrite the .env file in case ctl commands are executed.
This is specially important if extra environment variables are passed in the .env file

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add tests for control script

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix typo in github workflow

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix shell linting errors

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update .github/workflows/PR-build.yml

* Make debian aligned with RPM

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* properly install collector deb

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Use dpkg to install collector

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Properly use cache

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Move control script tests to the CI

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add the pr-build tests back

Signed-off-by: Raphael Silva <rapphil@gmail.com>

---------

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com>

* Fix control script to avoid sed special characters

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix typo in tests

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update release notes

Signed-off-by: Raphael Silva <rapphil@gmail.com>

---------

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com>

---------

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: Raphael Philipe Mendes da Silva <rapphil@gmail.com>
Co-authored-by: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com>
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.

2 participants