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

Use otelcol-config for config manipulations #103

Draft
wants to merge 164 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
e64fa8e
Use otelcol-config for config manipulations
ccressent Aug 2, 2024
97a27a4
Remove write_sumologic_extension
ccressent Aug 27, 2024
0eb43e2
Install otelcol-config in test-install-script job (#111)
echlebek Aug 28, 2024
39797a7
Remove the concept of systemd from install script
echlebek Aug 28, 2024
a6885de
Remove systemd concepts
echlebek Aug 28, 2024
de2a294
Remove unused code
echlebek Aug 28, 2024
388a81b
Move much of the script to otelcol-config
echlebek Aug 29, 2024
7445b33
Merge branch 'main' into osc800-otelcol-config-refactor
echlebek Aug 29, 2024
5719b04
Fix infinite loop in script
echlebek Aug 30, 2024
867c1c0
Return 2 on incorrect usage
echlebek Aug 30, 2024
6130a08
Hardcode app version for now
echlebek Aug 30, 2024
8e3b87e
Don't try to get latest release in install script tests
echlebek Aug 30, 2024
69c7ee0
Install package repositories with install.sh
echlebek Aug 30, 2024
ebb767e
Fix debian package uninstallation
echlebek Aug 30, 2024
bf3405a
Add -y to package removal calls
echlebek Aug 30, 2024
6ec1076
Test speculative change
echlebek Aug 30, 2024
38c9d60
Support --purge for apt-get
echlebek Aug 30, 2024
bbcce55
Use --purge in script tests
echlebek Aug 30, 2024
64972ac
Remove autoconfirm tests on linux
echlebek Aug 30, 2024
d5107a9
Don't do user checks
echlebek Aug 30, 2024
b1d188e
Fixes for darwin and windows
echlebek Aug 30, 2024
c9fadf8
Fix add-tag routine
echlebek Aug 30, 2024
a8510d1
Don't show usage for no args when token env set
echlebek Aug 30, 2024
76cfe53
use --quiet for calling package managers
echlebek Aug 30, 2024
be149ca
Fix crash when otelcol-config is not yet installed
echlebek Aug 30, 2024
2ec9db3
Use more --quiet
echlebek Aug 30, 2024
845bfb8
Use otelcol-config for darwin-specific subroutine
echlebek Aug 30, 2024
25fb279
Replace common.yaml with 00-otelcol-config-settings.yaml
echlebek Aug 30, 2024
f26db43
Merge branch 'main' into osc800-otelcol-config-refactor
echlebek Sep 3, 2024
c80cbe4
Complain when installation token not provided
echlebek Sep 3, 2024
9c9633b
Fix --download-only for Darwin
echlebek Sep 3, 2024
1162d97
Expect different permissions
echlebek Sep 3, 2024
ad9ec64
Prioritize token.env over config file
echlebek Sep 3, 2024
5ab63fc
Refactor and simplify
echlebek Sep 3, 2024
82d747e
Remove different tags tests
echlebek Sep 3, 2024
9e2dcd3
No arguments tests has exit code 1
echlebek Sep 3, 2024
98c6e98
Remove --skip-config
echlebek Sep 3, 2024
dc0f703
Better default for SKIP_TOKEN
echlebek Sep 3, 2024
90a9d68
Fix getopt
echlebek Sep 3, 2024
a52e39e
Don't support checking if the configuration works
echlebek Sep 3, 2024
b58c004
Remove darwin empty installation token test
echlebek Sep 3, 2024
5071e1a
Better test failure output
echlebek Sep 3, 2024
4fe1fa6
Remove unsupported test
echlebek Sep 3, 2024
ddc45f8
Don't try to write zero fields
echlebek Sep 3, 2024
dac9e5e
Don't check ownership and perms on Linux
echlebek Sep 3, 2024
9b0b958
Rely on packaged otelcol-config
echlebek Sep 3, 2024
0e11cda
Fix some test checks
echlebek Sep 4, 2024
822af3b
Make sure we are always saying yes
echlebek Sep 4, 2024
e2b9049
Say yes differently
echlebek Sep 4, 2024
1d6ae85
Don't check for token in config
echlebek Sep 4, 2024
2e9ef29
Don't check config created on Linux
echlebek Sep 4, 2024
94ba0a5
Fix ephemeral check
echlebek Sep 4, 2024
babd812
Don't check for token in config on Linux
echlebek Sep 4, 2024
88c79de
Mutating existing installations no longer supported on Linux
echlebek Sep 4, 2024
9f37502
Remove some more deprecated tests
echlebek Sep 4, 2024
38188a3
Fix checkConfigOverrided
echlebek Sep 4, 2024
84065f9
Fix getopts
echlebek Sep 4, 2024
ba4de6f
Tolerate missing config files in test
echlebek Sep 4, 2024
05d27a4
Slightly different checking for ephemeral
echlebek Sep 4, 2024
250aafa
Oops
echlebek Sep 4, 2024
46db5e5
Flip token env checks
echlebek Sep 4, 2024
e3ec61e
Attempt to fix Darwin build
echlebek Sep 4, 2024
a63dcb0
Tolerate missing otelcol-config for Darwin install
echlebek Sep 4, 2024
0fa1a9c
Add DARWIN_PKG_URL
echlebek Sep 4, 2024
3b3c9a4
Don't test with stale macOS pkg
echlebek Sep 4, 2024
cd9f0d9
Use separate job step for setting DARWIN_PKG_URL
amdprophet Sep 5, 2024
d2846d6
Move test-install-script job to build_packages workflow
amdprophet Sep 6, 2024
390bf57
Fix job dependency name
amdprophet Sep 6, 2024
7f00c29
Fix runner OS name in CI conditionals
amdprophet Sep 6, 2024
eb0396f
Try alternate conditional syntax
amdprophet Sep 6, 2024
d0801fe
Use runner.os instead of matrix.os
amdprophet Sep 6, 2024
7b3a745
Only download macOS intel package, use new method to determine pkg path
amdprophet Sep 6, 2024
a5a12c5
Pass DARWIN_PKG_URL to sudo env
amdprophet Sep 6, 2024
c62e1f3
debug
amdprophet Sep 6, 2024
d4c58ee
Fix package path
amdprophet Sep 6, 2024
0267670
Check DOWNLOAD_ONLY before complaining about token
echlebek Sep 9, 2024
b5afdbf
Change expected Darwin permissions
echlebek Sep 9, 2024
0098f16
Debug
echlebek Sep 9, 2024
da500ab
Don't chmod or chown in install script
echlebek Sep 9, 2024
39cfd2e
Set USER_TOKEN="" when USER_TOKEN==null
echlebek Sep 9, 2024
03c23f0
Change expected Linux perms
echlebek Sep 9, 2024
535be37
Fix hostmetrics, add ephemeral config (#114)
amdprophet Sep 17, 2024
d47a331
expect opamp.d to exist
amdprophet Sep 17, 2024
58d668c
debug
amdprophet Sep 17, 2024
cf2500a
try using powershell for tests on windows
amdprophet Sep 18, 2024
599551f
try using powershell for tests on windows
amdprophet Sep 18, 2024
9522fde
set timeout for test-install-script to 15 mins
amdprophet Sep 18, 2024
8186316
print launchdaemon state while waiting for start
amdprophet Sep 18, 2024
e349bdf
try kickstarting launchd service
amdprophet Sep 25, 2024
3cb7e45
try kickstarting launchd service
amdprophet Sep 25, 2024
73ea945
try starting launchd service
amdprophet Sep 26, 2024
97e7ce5
increase install-script-test timeout to 30m
amdprophet Sep 26, 2024
3a56a70
fix package installation on macOS
amdprophet Sep 26, 2024
5adfa26
debug
amdprophet Sep 27, 2024
85b875e
remove usage of testify's require
amdprophet Sep 28, 2024
7010b0c
appease the linter
amdprophet Sep 28, 2024
f83761a
add error return value to runTest
amdprophet Sep 28, 2024
a4ca84f
additional fixes
amdprophet Sep 28, 2024
4dbf5ec
additional fixes
amdprophet Sep 28, 2024
3ce37e2
increase install-script-test timeout to 60m
amdprophet Sep 28, 2024
e2ff9cc
create .keep file in opamp.d
amdprophet Oct 1, 2024
2df7127
fix variable name
amdprophet Oct 1, 2024
6136b8d
use assets dir, not artifacts dir
amdprophet Oct 1, 2024
bdeb6ef
add opamp.d/.keep to expected macOS files
amdprophet Oct 1, 2024
72066aa
try different install script logic
amdprophet Oct 3, 2024
683979e
Fix previous commit
echlebek Oct 3, 2024
e99e7ea
Allow skipping installation token even if not previously provided
echlebek Oct 3, 2024
6357b0a
Fix another test
echlebek Oct 3, 2024
3c42df4
Remove unnecessary test
echlebek Oct 3, 2024
672fff1
return true if ephemeral.yaml cannot be read
amdprophet Oct 3, 2024
6e5b707
Expect install code zero when skip install token on Linux
echlebek Oct 3, 2024
ed80193
Mention how api base url differs from configured api url
echlebek Oct 3, 2024
1c74973
Check for null output from otelcol-config --read-kv
echlebek Oct 3, 2024
118deb0
Don't download otelcol-config separately
echlebek Oct 3, 2024
1b32de3
Revert "Don't download otelcol-config separately"
echlebek Oct 3, 2024
4c25952
Dump plist temporarily
echlebek Oct 3, 2024
b3f5213
Fix test expectations for a few tests
echlebek Oct 3, 2024
3491c0d
Make sure test base URLs are URLs
echlebek Oct 3, 2024
ba9bf73
Revert "Dump plist temporarily"
echlebek Oct 3, 2024
ef8ef70
install version built by same run
amdprophet Oct 4, 2024
c3d23b4
fix cmd format for specifying apt pkg versions
amdprophet Oct 4, 2024
20a2d44
remove unnecessary version code from install.sh
amdprophet Oct 4, 2024
f3dd80c
debug
amdprophet Oct 4, 2024
f22e862
add missing version to package_with_version
amdprophet Oct 4, 2024
af85200
debug
amdprophet Oct 4, 2024
dbcf842
fix version flag logic
amdprophet Oct 4, 2024
6f4620b
remove condition for now
amdprophet Oct 4, 2024
8f8d2da
pass version through Makefile
amdprophet Oct 4, 2024
7e3324d
fix typo
amdprophet Oct 4, 2024
bb71332
Handle existing installations
ccressent Oct 9, 2024
6249036
Fix linting issue
ccressent Oct 9, 2024
0d64993
Ignore unbound variable
ccressent Oct 9, 2024
756e2eb
Add configuration restoration message
ccressent Oct 16, 2024
27332da
Update configuration restoration message
ccressent Oct 16, 2024
13fdcef
install.sh fixes for macOS, improve testing
amdprophet Oct 19, 2024
aa8a6c9
remove non-existent linux checks
amdprophet Oct 19, 2024
ede639f
attempt to fix remaining darwin tests
amdprophet Oct 19, 2024
2b3bb75
fix bad function name
amdprophet Oct 19, 2024
519d652
add .op directory to .gitignore
amdprophet Oct 21, 2024
e567275
use service wrapper on linux & macOS
amdprophet Oct 23, 2024
2a150bb
remove unusused function
amdprophet Oct 23, 2024
0754453
remove unused var
amdprophet Oct 23, 2024
ec56ffe
remove unused vars
amdprophet Oct 23, 2024
436425c
add missing file to expected files
amdprophet Oct 23, 2024
08cb85e
use /usr/local/share on macOS
amdprophet Oct 23, 2024
c764bc3
fix launchd perms, path to service wrapper
amdprophet Oct 24, 2024
4ad9bf2
Rewrite package repositories URLs
ccressent Oct 25, 2024
8064f23
wait for packages to be indexed before testing
amdprophet Oct 25, 2024
c11bc62
fix packagecloud-go command name
amdprophet Oct 25, 2024
7752295
set PACKAGECLOUD_TOKEN
amdprophet Oct 25, 2024
1859e27
increase wait-for-index to 30s, bump packagecloud-go to 0.2.1
amdprophet Oct 25, 2024
e897f59
use repo_id for url replacement
amdprophet Oct 25, 2024
d7ee5c4
replace packagecloud.io with packages.sumologic.com in apt auth file
amdprophet Oct 25, 2024
1af5451
fix path to apt auth file
amdprophet Oct 25, 2024
c8881ff
only wait for relevant packages to be indexed
amdprophet Oct 25, 2024
62cdd19
bump packagecloud-go in dockerfile
amdprophet Oct 25, 2024
daab579
don't require packagecloud-go
amdprophet Oct 25, 2024
fad8a6a
add missing packagecloud token
amdprophet Oct 25, 2024
d8bbf60
debug
amdprophet Oct 25, 2024
8d55d3a
syntax error
amdprophet Oct 25, 2024
533463d
debug
amdprophet Oct 25, 2024
ac34489
debug
amdprophet Oct 25, 2024
27cb13d
debug
amdprophet Oct 25, 2024
7021e22
remove debug
amdprophet Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .github/workflows/_reusable_build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Download packagecloud-go tool
run: |
baseURL="https://github.com/amdprophet/packagecloud-go/releases/download"
version="0.1.5"
file="packagecloud-go_${version}_linux_amd64.tar.gz"
curl -Lo /tmp/packagecloud-go.tar.gz $baseURL/$version/$file

- name: Install packagecloud-go tool
run: |
tar -C /tmp -zxf /tmp/packagecloud-go.tar.gz
sudo mv /tmp/packagecloud /usr/local/bin

- name: Workflow URL for sumologic-otel-collector
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }}
run: |
Expand Down Expand Up @@ -235,6 +223,13 @@ jobs:
target: publish-package
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: Wait for Packagecloud packages to be indexed
if: runner.os == 'Linux'
uses: ./ci/github-actions/make
with:
target: wait-for-packagecloud-indexing
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}

test_package:
runs-on: ${{ inputs.runs_on }}
name: Test (CMake)
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/build_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,74 @@ jobs:
This release packages [${{ env.OTC_APP_VERSION }}](https://github.com/SumoLogic/sumologic-otel-collector/releases/tag/${{ env.OTC_APP_VERSION }}).

The changelog below is for the package itself, rather than the Sumo Logic Distribution for OpenTelemetry Collector.

test-install-script:
name: Test Install Script
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 60
needs:
- determine_version
- build_packages
strategy:
fail-fast: false
matrix:
include:
- arch_os: linux_amd64
runs_on: ubuntu-20.04
- arch_os: darwin_amd64
runs_on: macos-latest
- arch_os: windows_amd64
runs_on: windows-2022
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_CI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTC_VERSION: ${{ needs.determine_version.outputs.otc_version }}
OTC_BUILD_NUMBER: ${{ github.run_number }}
PACKAGECLOUD_MASTER_TOKEN: ${{ secrets.PACKAGECLOUD_MASTER_TOKEN }}
PACKAGECLOUD_REPO: ci-builds
steps:
- uses: actions/checkout@v4

- name: Check if test related files changed
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
install-script/**/*
.github/**

- name: Setup go
if: steps.changed-files.outputs.any_changed == 'true'
uses: WillAbides/setup-go-faster@v1
with:
go-version: stable

- name: Download macOS package and use it for install.sh
if: ${{ steps.changed-files.outputs.any_changed == 'true' && runner.os == 'macOS' }}
uses: actions/download-artifact@v4
with:
path: artifacts/
pattern: otelcol-sumo_*-intel.pkg

- name: Show packages
if: ${{ steps.changed-files.outputs.any_changed == 'true' && runner.os == 'macOS' }}
run: |
ls -l artifacts/
ls -l artifacts/**/*

- name: Set DARWIN_PKG_URL
if: ${{ steps.changed-files.outputs.any_changed == 'true' && runner.os == 'macOS' }}
run: |
fp="$(readlink -f artifacts/otelcol-sumo_*-intel.pkg/otelcol-sumo_*-intel.pkg)"
echo DARWIN_PKG_URL="file://${fp}" >> $GITHUB_ENV

- name: Run install script tests (*nix)
if: steps.changed-files.outputs.any_changed == 'true' && runner.os != 'Windows'
working-directory: install-script/test
run: make test

- name: Run install script tests (Windows)
shell: powershell
if: steps.changed-files.outputs.any_changed == 'true' && runner.os == 'Windows'
working-directory: install-script/test
run: make test
47 changes: 0 additions & 47 deletions .github/workflows/test-install-script.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ wix/packages
msi/wix/packages
msi/SumoLogic.wixext/packages
install-script/test/sumologic_scripts_tests.test

# 1Password
.op/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.24.1 FATAL_ERROR)

# Required and optional programs. Attempts to find required and optional
# programs used to build the packages.
find_program(PACKAGECLOUD_PROGRAM packagecloud REQUIRED)
find_program(PACKAGECLOUD_PROGRAM packagecloud)

# Set version information
include("${CMAKE_SOURCE_DIR}/version.cmake")
Expand Down
Empty file added assets/.keep
Empty file.
3 changes: 3 additions & 0 deletions assets/conf.d/ephemeral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extensions:
sumologic:
ephemeral: true
11 changes: 5 additions & 6 deletions assets/productbuild/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ collector_files=(
"/etc/otelcol-sumo/sumologic.yaml"
"/etc/otelcol-sumo/conf.d"
"/etc/otelcol-sumo/conf.d-available"
"/etc/otelcol-sumo/conf.d-available/ephemeral.yaml"
"/etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
"/etc/otelcol-sumo"
"/etc/otelcol-sumo/opamp.d"
"/usr/local/bin/otelcol-config"
"/usr/local/bin/otelcol-sumo"
"/usr/local/share/otelcol-sumo/otelcol-sumo.sh"
"/usr/local/share/otelcol-sumo"
"/var/lib/otelcol-sumo/file_storage"
"/var/lib/otelcol-sumo"
"/var/log/otelcol-sumo"
)

# A list of files & directories to remove for hostmetrics
hostmetrics_files=(
"/etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
)

function package_is_registered() {
package_id="$1"
pkgutil --pkg-info "$package_id"
Expand Down Expand Up @@ -114,7 +114,6 @@ function uninstall_package() {

stop_service "${service_plist_file}"
uninstall_package "com.sumologic.otelcol-sumo" "${collector_files[@]}"
uninstall_package "com.sumologic.otelcol-sumo-hostmetrics" "${hostmetrics_files[@]}"

# remove the directory that this script belongs to
SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
Expand Down
11 changes: 6 additions & 5 deletions assets/services/launchd/com.sumologic.otelcol-sumo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
<string>otelcol-sumo</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/otelcol-sumo</string>
<string>--config</string>
<string>/etc/otelcol-sumo/sumologic.yaml</string>
<string>--config</string>
<string>glob:/etc/otelcol-sumo/conf.d/*.yaml</string>
<string>/usr/local/share/otelcol-sumo/otelcol-sumo.sh</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>SUMOLOGIC_INSTALLATION_TOKEN</key>
<string></string>
</dict>
<!-- Service user -->
<key>UserName</key>
<string>_otelcol-sumo</string>
Expand Down
2 changes: 1 addition & 1 deletion assets/services/systemd/otelcol-sumo.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=Sumo Logic Distribution for OpenTelemetry Collector

[Service]
ExecStart=/usr/local/bin/otelcol-sumo --config /etc/otelcol-sumo/sumologic.yaml --config "glob:/etc/otelcol-sumo/conf.d/*.yaml"
ExecStart=/usr/share/otelcol-sumo/otelcol-sumo.sh
User=otelcol-sumo
Group=otelcol-sumo
MemoryHigh=2000M
Expand Down
63 changes: 8 additions & 55 deletions ci/verify_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ system_files=(
"usr"
"usr/local"
"usr/local/bin"
"usr/local/share"
"var"
"var/lib"
"var/log"
Expand All @@ -48,23 +49,24 @@ expected_collector_files=(
"etc/otelcol-sumo/conf.d"
"etc/otelcol-sumo/conf.d/common.yaml"
"etc/otelcol-sumo/conf.d-available"
"etc/otelcol-sumo/conf.d-available/ephemeral.yaml"
"etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
"etc/otelcol-sumo/conf.d-available/examples"
"etc/otelcol-sumo/opamp.d"
"etc/otelcol-sumo/opamp.d/.keep"
"etc/otelcol-sumo/sumologic.yaml"
"Library/Application Support/otelcol-sumo"
"Library/Application Support/otelcol-sumo/uninstall.sh"
"Library/LaunchDaemons/com.sumologic.otelcol-sumo.plist"
"usr/local/bin/otelcol-config"
"usr/local/bin/otelcol-sumo"
"usr/local/share/otelcol-sumo"
"usr/local/share/otelcol-sumo/otelcol-sumo.sh"
"var/lib/otelcol-sumo"
"var/lib/otelcol-sumo/file_storage"
"var/log/otelcol-sumo"
)

# a list of files that the hostmetrics package should install
expected_hostmetrics_files=(
"etc/otelcol-sumo/conf.d-available/hostmetrics.yaml"
)

function install_package() {
mpkg="$1"
mpkg_basename="$2"
Expand Down Expand Up @@ -184,15 +186,9 @@ while IFS= read -r -d $'\0'; do
collector_pkg+=("$REPLY")
done < <(find . -name "*-otelcol-sumo.pkg" -type d -print0)

# create an array of hostmetrics packages (only one is expected)
hostmetrics_pkg=()
while IFS= read -r -d $'\0'; do
hostmetrics_pkg+=("$REPLY")
done < <(find . -name "*-otelcol-sumo-hostmetrics.pkg" -type d -print0)

# verify that the expected number of sub-packages were found
pkg_count="${#all_pkgs[@]}"
expected_pkg_count=2
expected_pkg_count=1

if [ "$pkg_count" -ne $expected_pkg_count ]; then
echo "error: ${expected_pkg_count} sub-packages were expected but found ${pkg_count}"
Expand All @@ -205,12 +201,6 @@ if [ "${#collector_pkg[@]}" -gt 1 ]; then
exit 1
fi

# only one hostmetrics sub-package should exist
if [ "${#hostmetrics_pkg[@]}" -gt 1 ]; then
echo "error: more than one hostmetrics sub-package was found"
exit 1
fi

# get a list of files installed by the collector sub-package excluding system
# files
collector_pkg_name="$(echo "${collector_pkg[0]}" | cut -d/ -f2-)"
Expand Down Expand Up @@ -243,41 +233,6 @@ for f in "${all_collector_files[@]}"; do
collector_files+=("$collector_file")
done

cd "$expanded_dir" || exit

# get a list of files installed by the hostmetrics sub-package excluding both
# system files and collector files
hostmetrics_pkg_name="$(echo "${hostmetrics_pkg[0]}" | cut -d/ -f2-)"
cd "${hostmetrics_pkg_name}/Payload" || exit
all_hostmetrics_files=()
while IFS= read -r -d $'\0'; do
all_hostmetrics_files+=("$REPLY")
done < <(find . ! -name '.' -print0)

hostmetrics_files=()

for f in "${all_hostmetrics_files[@]}"; do
hostmetrics_file="$(echo "$f" | cut -d/ -f2-)"

# shellcheck disable=SC2076
if [[ " ${system_files[*]} " =~ " ${hostmetrics_file} " ]]; then
continue
fi

# shellcheck disable=SC2076
if [[ " ${collector_files[*]} " =~ " ${hostmetrics_file} " ]]; then
continue
fi

# shellcheck disable=SC2076
if [[ ! " ${expected_collector_files[*]} " =~ " ${collector_file} " ]]; then
echo "error: unexpected file installed by hostmetrics sub-package: ${hostmetrics_file}"
exit 1
fi

hostmetrics_files+=("$hostmetrics_file")
done

cd "$exec_dir" || exit

install_package "$mpkg" "$mpkg_basename"
Expand All @@ -287,7 +242,6 @@ echo "##########################################################################
echo "Verifying installation: ${mpkg}"
echo "################################################################################"
verify_installation "com.sumologic.otelcol-sumo" "${expected_collector_files[@]}"
verify_installation "com.sumologic.otelcol-sumo-hostmetrics" "${expected_hostmetrics_files[@]}"

echo
echo "################################################################################"
Expand All @@ -305,6 +259,5 @@ echo "##########################################################################
echo "Verifying uninstallation: ${mpkg}"
echo "################################################################################"
verify_uninstallation "com.sumologic.otelcol-sumo" "${expected_collector_files[@]}"
verify_uninstallation "com.sumologic.otelcol-sumo-hostmetrics" "${expected_hostmetrics_files[@]}"

echo "Success!"
Loading
Loading