diff --git a/.github/scripts/test-collector-ctl.sh b/.github/scripts/test-collector-ctl.sh new file mode 100755 index 0000000000..958f5cfc3a --- /dev/null +++ b/.github/scripts/test-collector-ctl.sh @@ -0,0 +1,74 @@ +#!/bin/bash -x + +set -e + +# This script is supposed to run during the CI to validate that the control +# script is working as expected +# Important: this script requires root permission. + +COLLECTOR_DEB=$1 +COLLECTOR_CONFIG=$2 + +ADOT_CTL=/opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl +ENV_FILE="/opt/aws/aws-otel-collector/etc/.env" +CONFIG_FILE="/opt/aws/aws-otel-collector/etc/config.yaml" + +setup() { + dpkg -i "$COLLECTOR_DEB" +} + +test_collector_ctl_does_not_overwrite_env() { + $ADOT_CTL -a start + if [ ! -e $CONFIG_FILE ]; then + echo "Config file does not exist" + exit 1 + fi + + echo "EXTRA_ENV=\"some value\"" | tee -a $ENV_FILE > /dev/null + + # We don't need the collector to succeed, just that the control script is execised + $ADOT_CTL -a start -c "http://example.com" + + if ! grep -q EXTRA_ENV "$ENV_FILE"; then + echo "Env file was overwritten" + exit 1 + fi + + $ADOT_CTL -a start -c "$COLLECTOR_CONFIG" + if ! grep -q EXTRA_ENV "$ENV_FILE"; then + ehco "Env file was overwritten" + exit 1 + fi + echo "${FUNCNAME[0]} ... OK" +} + +test_collector_ctl_with_sed_special_chars() { + # ampersand is a special character in sed + cfg="https://example.com?test=1&test=2" + $ADOT_CTL -a start -c "$cfg" + + expected_string="^config=\"--config '${cfg}'\"$" + + if ! grep -q "${expected_string}" "$ENV_FILE"; then + echo "Configuration is incorrect" + exit 1 + fi + + cfg="./config.yaml" + $ADOT_CTL -a start -c "$cfg" + + expected_string="^config=\"--config /opt/aws/aws-otel-collector/etc/config.yaml\"$" + if ! grep -q "${expected_string}" "$ENV_FILE"; then + echo "Configuration is incorrect" + exit 1 + fi + + echo "${FUNCNAME[0]} ... OK" +} + + +setup + +## Tests +test_collector_ctl_does_not_overwrite_env +test_collector_ctl_with_sed_special_chars diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0c93f1f9c9..c384a11900 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -379,6 +379,27 @@ jobs: run: | gpg --fingerprint --with-colons aws-otel-collector@amazon.com grep "^fpr" | sed -n 's/^fpr:::::::::\([[:alnum:]]\+\):/\1/p' | xargs gpg --batch --yes --delete-secret-keys gpg --list-secret-keys + + test-control-stript: + runs-on: ubuntu-latest + needs: [packaging-deb] + steps: + - name: Checkout + if: ${{ needs.changes.outputs.changed == 'true' }} + uses: actions/checkout@v3 + + - name: Restore cached Debs + if: ${{ needs.changes.outputs.changed == 'true' }} + uses: actions/cache@v3 + with: + key: "cached_debs_${{ github.run_id }}" + path: ${{ env.PACKAGING_ROOT }} + + - name: Execute tests + if: ${{ needs.changes.outputs.changed == 'true' }} + run: | + sudo ./.github/scripts/test-collector-ctl.sh $PACKAGING_ROOT/debian/amd64/aws-otel-collector.deb ./config.yaml + packaging-ssm: runs-on: ubuntu-latest needs: [packaging-rpm, packaging-deb, packaging-msi] diff --git a/.github/workflows/PR-build.yml b/.github/workflows/PR-build.yml index 2fdff0bce6..5273a17856 100644 --- a/.github/workflows/PR-build.yml +++ b/.github/workflows/PR-build.yml @@ -247,12 +247,40 @@ jobs: key: "cached_binaries_${{ github.run_id }}" path: build + - name: Cache built debian + if: ${{ needs.changes.outputs.changed == 'true' }} + uses: actions/cache@v3 + with: + key: "cached_deb_${{ github.run_id }}" + path: build/packages/debian + - name: Build Debs if: ${{ needs.changes.outputs.changed == 'true' }} run: | 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: + runs-on: ubuntu-latest + needs: [changes, packaging-deb] + steps: + - name: Checkout + if: ${{ needs.changes.outputs.changed == 'true' }} + uses: actions/checkout@v3 + + - name: Restore cached deb + if: ${{ needs.changes.outputs.changed == 'true' }} + uses: actions/cache@v3 + with: + key: "cached_deb_${{ github.run_id }}" + path: build/packages/debian + + - name: Execute tests + if: ${{ needs.changes.outputs.changed == 'true' }} + run: | + file ./build/packages/debian/amd64/aws-otel-collector.deb + sudo ./.github/scripts/test-collector-ctl.sh ./build/packages/debian/amd64/aws-otel-collector.deb ./config.yaml + get-test-cases: runs-on: ubuntu-latest outputs: diff --git a/VERSION b/VERSION index 7021025f31..420000f959 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.31.0 +v0.32.0 diff --git a/docs/releases/v0.32.0.md b/docs/releases/v0.32.0.md new file mode 100644 index 0000000000..91a53f269b --- /dev/null +++ b/docs/releases/v0.32.0.md @@ -0,0 +1,23 @@ +# Changelog + +## [v0.32.0](https://github.com/aws-observability/aws-otel-collector/tree/v0.32.0) (2023-08-11) + +[Full Changelog](https://github.com/aws-observability/aws-otel-collector/compare/v0.31.0...v0.32.0) + +**Merged pull requests:** + +- dependabot updates Fri Aug 11 04:54:36 UTC 2023 [\#2264](https://github.com/aws-observability/aws-otel-collector/pull/2264) +- Add the load balancing exporter and k8s attributes processor [\#2262](https://github.com/aws-observability/aws-otel-collector/pull/2262) ([humivo](https://github.com/humivo)) +- Add Log statement about statsd receiver [\#2250](https://github.com/aws-observability/aws-otel-collector/pull/2250) ([vasireddy99](https://github.com/vasireddy99)) +- Dependabot updates [\#2245](https://github.com/aws-observability/aws-otel-collector/pull/2245) ([vasireddy99](https://github.com/vasireddy99)) +- \[chore\] Add Patch file for kafka exporter [\#2244](https://github.com/aws-observability/aws-otel-collector/pull/2244) ([vasireddy99](https://github.com/vasireddy99)) +- \[main\] Vendor modules and add patch file for StatsD Receiver [\#2241](https://github.com/aws-observability/aws-otel-collector/pull/2241) ([vasireddy99](https://github.com/vasireddy99)) +- Dependabot prs/2023 08 01 t120653 and OTel Collector v0.82.0 [\#2229](https://github.com/aws-observability/aws-otel-collector/pull/2229) ([vasireddy99](https://github.com/vasireddy99)) +- Adding ECS\_Observer\_Test\_Case [\#2227](https://github.com/aws-observability/aws-otel-collector/pull/2227) ([PaurushGarg](https://github.com/PaurushGarg)) +- \[chore\] update main branch with release/v0.31.x [\#2213](https://github.com/aws-observability/aws-otel-collector/pull/2213) ([bryan-aguilar](https://github.com/bryan-aguilar)) +- \[chore\] Add missing cluster targets [\#2212](https://github.com/aws-observability/aws-otel-collector/pull/2212) ([bryan-aguilar](https://github.com/bryan-aguilar)) +- \[chore\] Store and use testcases file from collector repo [\#2205](https://github.com/aws-observability/aws-otel-collector/pull/2205) ([bryan-aguilar](https://github.com/bryan-aguilar)) +- \[fix\] Don't overwrite systemd environment file [\#2261](https://github.com/aws-observability/aws-otel-collector/pull/2261) [\#2267](https://github.com/aws-observability/aws-otel-collector/pull/2267) ([rapphil](https://github.com/rapphil)) + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/tools/ctl/linux/aws-otel-collector-ctl.sh b/tools/ctl/linux/aws-otel-collector-ctl.sh index 061d165a5b..8846bb3cce 100644 --- a/tools/ctl/linux/aws-otel-collector-ctl.sh +++ b/tools/ctl/linux/aws-otel-collector-ctl.sh @@ -53,7 +53,8 @@ UsageString=" aoc_config_remote_uri() { config="${1:-}" - echo "config=\"--config ${config}\"" > $ENV_FILE + sed -i '/^config=.*$/d' $ENV_FILE + echo "config=\"--config '${config}'\"" >> $ENV_FILE } @@ -63,12 +64,20 @@ aoc_config_local_uri() { # Strip the file scheme in case it is present config="${config#file:}" - echo "config=\"--config /opt/aws/aws-otel-collector/etc/config.yaml\"" > $ENV_FILE + sed -i '/^config=.*$/d' $ENV_FILE + echo "config=\"--config /opt/aws/aws-otel-collector/etc/config.yaml\"" >> $ENV_FILE + if [ -n "$config" ] && [ -f "$config" ]; then cp "$config" $CONFDIR/config.yaml + else + echo "File $config does not exist" + exit 1 fi +} +# Used in case the collector starts for the first time without a configuration parameter +aoc_ensure_default_config() { if [ ! -f $CONFDIR/config.yaml ]; then cp $DFT_CONFDIR/.config.yaml $CONFDIR/config.yaml fi @@ -87,10 +96,15 @@ is_remote_uri() { aoc_start() { config="${1:-}" - if is_remote_uri "$config"; then - aoc_config_remote_uri "$config" + # The previous configuration should be used if no configuration parameter is passed + if [ -z "$config" ]; then + aoc_ensure_default_config else - aoc_config_local_uri "$config" + if is_remote_uri "$config"; then + aoc_config_remote_uri "$config" + else + aoc_config_local_uri "$config" + fi fi if [ "${SYSTEMD}" = 'true' ]; then diff --git a/tools/packaging/debian/create_deb.sh b/tools/packaging/debian/create_deb.sh index 326afcec2e..60b4bb2219 100755 --- a/tools/packaging/debian/create_deb.sh +++ b/tools/packaging/debian/create_deb.sh @@ -46,7 +46,8 @@ 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 +cp config.yaml "${AOC_ROOT}/opt/aws/aws-otel-collector/var/.config.yaml" cp .env "${AOC_ROOT}/opt/aws/aws-otel-collector/etc" cp extracfg.txt "${AOC_ROOT}/opt/aws/aws-otel-collector/etc" cp tools/packaging/linux/aws-otel-collector.service "${AOC_ROOT}/etc/systemd/system/" @@ -54,7 +55,6 @@ cp tools/packaging/linux/aws-otel-collector.conf "${AOC_ROOT}/etc/init/" chmod ug+rx "${AOC_ROOT}/opt/aws/aws-otel-collector/bin/aws-otel-collector" chmod ug+rx "${AOC_ROOT}/opt/aws/aws-otel-collector/bin/aws-otel-collector-ctl" -chmod ug+rx "${AOC_ROOT}/opt/aws/aws-otel-collector/etc/config.yaml" chmod ug+rx "${AOC_ROOT}/opt/aws/aws-otel-collector/etc/.env" chmod ug+rx "${AOC_ROOT}/opt/aws/aws-otel-collector/etc/extracfg.txt" diff --git a/tools/packaging/windows/aws-otel-collector.wxs b/tools/packaging/windows/aws-otel-collector.wxs index f6b2693456..bb02500a9c 100644 --- a/tools/packaging/windows/aws-otel-collector.wxs +++ b/tools/packaging/windows/aws-otel-collector.wxs @@ -3,7 +3,7 @@