From e9fd7d8b8bdd8c1acc063f8521a66592eb8fe6bf Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Thu, 11 May 2023 15:38:57 -0400 Subject: [PATCH 1/5] add another error exclusion to so-verify --- setup/so-verify | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/so-verify b/setup/so-verify index 84f02e43c..a89e24120 100755 --- a/setup/so-verify +++ b/setup/so-verify @@ -31,6 +31,8 @@ log_has_errors() { # Ignore Failed: 0 since that is the salt state output, and we detect state failures # via Result: False already. + + # Ignore "/tmp/__salt.tmp." and "retcode: 126" as they seem to be related to a transient issue with the elastic agent for linux grep -E "FAILED|Failed|failed|ERROR|Result: False" "$setup_log" | \ grep -vE "The Salt Master has cached the public key for this node" | \ @@ -44,6 +46,8 @@ log_has_errors() { grep -vE "Exception in callback None" | \ grep -vE "deprecation: ERROR" | \ grep -vE "code: 100" | \ + grep -vE "/tmp/__salt.tmp." | \ + grep -vE "retcode: 126" | \ grep -vE "Running scope as unit" &> "$error_log" if [[ $? -eq 0 ]]; then From f9890778ada6c3581b1e9211adfb95f7c8c156e0 Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Thu, 11 May 2023 16:45:46 -0400 Subject: [PATCH 2/5] revert last change to so-verify --- setup/so-verify | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup/so-verify b/setup/so-verify index a89e24120..7345ae4ab 100755 --- a/setup/so-verify +++ b/setup/so-verify @@ -32,8 +32,6 @@ log_has_errors() { # Ignore Failed: 0 since that is the salt state output, and we detect state failures # via Result: False already. - # Ignore "/tmp/__salt.tmp." and "retcode: 126" as they seem to be related to a transient issue with the elastic agent for linux - grep -E "FAILED|Failed|failed|ERROR|Result: False" "$setup_log" | \ grep -vE "The Salt Master has cached the public key for this node" | \ grep -vE "Minion failed to authenticate with the master" | \ @@ -46,8 +44,6 @@ log_has_errors() { grep -vE "Exception in callback None" | \ grep -vE "deprecation: ERROR" | \ grep -vE "code: 100" | \ - grep -vE "/tmp/__salt.tmp." | \ - grep -vE "retcode: 126" | \ grep -vE "Running scope as unit" &> "$error_log" if [[ $? -eq 0 ]]; then From d8e0e320f4c96c80bb48dc7de6377ebe0d976c0e Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Mon, 15 May 2023 07:31:32 -0400 Subject: [PATCH 3/5] so-elastic-agent-gen-installers should use /nsm to avoid filling /tmp --- .../so-elastic-agent-gen-installers | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers index 44c352352..32c05e811 100755 --- a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers +++ b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers @@ -20,26 +20,26 @@ FLEETHOST="{{ GLOBALS.manager_ip }}" TARGETOS=( "linux" "darwin" "windows" ) printf "\n### Get rid of any previous runs\n" -rm -rf /tmp/elastic-agent-workspace -mkdir -p /tmp/elastic-agent-workspace +rm -rf /nsm/elastic-agent-workspace +mkdir -p /nsm/elastic-agent-workspace printf "\n### Extract outer tarball and then each individual tarball/zip\n" -tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /tmp/elastic-agent-workspace/ -unzip /tmp/elastic-agent-workspace/elastic-agent-*.zip -d /tmp/elastic-agent-workspace/ -for archive in /tmp/elastic-agent-workspace/*.tar.gz +tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /nsm/elastic-agent-workspace/ +unzip /nsm/elastic-agent-workspace/elastic-agent-*.zip -d /nsm/elastic-agent-workspace/ +for archive in /nsm/elastic-agent-workspace/*.tar.gz do - tar xf "$archive" -C /tmp/elastic-agent-workspace/ + tar xf "$archive" -C /nsm/elastic-agent-workspace/ done printf "\n### Strip out unused components" -find /tmp/elastic-agent-workspace/elastic-agent-*/data/elastic-agent-*/components -regex '.*fleet.*\|.*packet.*\|.*apm*.*\|.*audit.*\|.*heart.*\|.*cloud.*' -delete +find /nsm/elastic-agent-workspace/elastic-agent-*/data/elastic-agent-*/components -regex '.*fleet.*\|.*packet.*\|.*apm*.*\|.*audit.*\|.*heart.*\|.*cloud.*' -delete printf "\n### Tar everything up again" for OS in "${TARGETOS[@]}" do - rm -rf /tmp/elastic-agent-workspace/elastic-agent - mv /tmp/elastic-agent-workspace/elastic-agent-*-$OS-x86_64 /tmp/elastic-agent-workspace/elastic-agent - tar -czvf /tmp/elastic-agent-workspace/$OS.tar.gz -C /tmp/elastic-agent-workspace elastic-agent + rm -rf /nsm/elastic-agent-workspace/elastic-agent + mv /nsm/elastic-agent-workspace/elastic-agent-*-$OS-x86_64 /nsm/elastic-agent-workspace/elastic-agent + tar -czvf /nsm/elastic-agent-workspace/$OS.tar.gz -C /nsm/elastic-agent-workspace elastic-agent done printf "\n### Generate OS packages using the cleaned up tarballs" @@ -48,7 +48,7 @@ do printf "\n\n### Generating $OS Installer...\n" docker run -e CGO_ENABLED=0 -e GOOS=$OS \ --mount type=bind,source=/etc/ssl/certs/,target=/workspace/files/cert/ \ - --mount type=bind,source=/tmp/elastic-agent-workspace/,target=/workspace/files/elastic-agent/ \ + --mount type=bind,source=/nsm/elastic-agent-workspace/,target=/workspace/files/elastic-agent/ \ --mount type=bind,source=/opt/so/saltstack/local/salt/elasticfleet/files/so_agent-installers/,target=/output/ \ {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent-builder:{{ GLOBALS.so_version }} go build -ldflags "-X main.fleetHost=$FLEETHOST -X main.enrollmentToken=$ENROLLMENTOKEN" -o /output/so-elastic-agent_$OS printf "\n### $OS Installer Generated...\n" From b01367a294f69e39a9a1f28ee8632430ec8ad9be Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Mon, 15 May 2023 08:41:05 -0400 Subject: [PATCH 4/5] remove the temp directory when finished --- .../tools/sbin_jinja/so-elastic-agent-gen-installers | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers index 32c05e811..558196e4c 100755 --- a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers +++ b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers @@ -53,3 +53,6 @@ do {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent-builder:{{ GLOBALS.so_version }} go build -ldflags "-X main.fleetHost=$FLEETHOST -X main.enrollmentToken=$ENROLLMENTOKEN" -o /output/so-elastic-agent_$OS printf "\n### $OS Installer Generated...\n" done + +printf "\n### Cleaning up temp files in /nsm/elastic-agent-workspace" +rm -rf /nsm/elastic-agent-workspace From 83188401c57add423cfa62b17792bef03435beab Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Mon, 15 May 2023 08:43:53 -0400 Subject: [PATCH 5/5] update status messages --- .../tools/sbin_jinja/so-elastic-agent-gen-installers | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers index 558196e4c..52d224e5e 100755 --- a/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers +++ b/salt/elasticfleet/tools/sbin_jinja/so-elastic-agent-gen-installers @@ -19,11 +19,11 @@ FLEETHOST="{{ GLOBALS.manager_ip }}" #ENROLLMENTOKEN=$2 TARGETOS=( "linux" "darwin" "windows" ) -printf "\n### Get rid of any previous runs\n" +printf "\n### Creating a temp directory at /nsm/elastic-agent-workspace\n" rm -rf /nsm/elastic-agent-workspace mkdir -p /nsm/elastic-agent-workspace -printf "\n### Extract outer tarball and then each individual tarball/zip\n" +printf "\n### Extracting outer tarball and then each individual tarball/zip\n" tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /nsm/elastic-agent-workspace/ unzip /nsm/elastic-agent-workspace/elastic-agent-*.zip -d /nsm/elastic-agent-workspace/ for archive in /nsm/elastic-agent-workspace/*.tar.gz @@ -31,10 +31,10 @@ do tar xf "$archive" -C /nsm/elastic-agent-workspace/ done -printf "\n### Strip out unused components" +printf "\n### Stripping out unused components" find /nsm/elastic-agent-workspace/elastic-agent-*/data/elastic-agent-*/components -regex '.*fleet.*\|.*packet.*\|.*apm*.*\|.*audit.*\|.*heart.*\|.*cloud.*' -delete -printf "\n### Tar everything up again" +printf "\n### Tarring everything up again" for OS in "${TARGETOS[@]}" do rm -rf /nsm/elastic-agent-workspace/elastic-agent @@ -42,7 +42,7 @@ do tar -czvf /nsm/elastic-agent-workspace/$OS.tar.gz -C /nsm/elastic-agent-workspace elastic-agent done -printf "\n### Generate OS packages using the cleaned up tarballs" +printf "\n### Generating OS packages using the cleaned up tarballs" for OS in "${TARGETOS[@]}" do printf "\n\n### Generating $OS Installer...\n"