From a595aea382b7c9d0d80363ce96c8906f43756143 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 21 Oct 2024 12:55:05 +0200 Subject: [PATCH 1/5] add check and basic support for technology configuration via env var --- bin/compile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/compile b/bin/compile index 58b161c..a82a9dd 100644 --- a/bin/compile +++ b/bin/compile @@ -39,7 +39,7 @@ downloadAgent() { puts_error "Neither curl nor wget executable found!" exit 1 fi - + local RETRYTIMEOUT=0 local DOWNLOADERRORS=0 while [[ $DOWNLOADERRORS -lt 3 ]]; do @@ -47,7 +47,7 @@ downloadAgent() { puts_step "Downloading OneAgent installer from ${DOWNLOADURL}" $DOWNLOADCOMMAND --header "$DOWNLOADHEADER" - + if [[ $? != 0 ]]; then DOWNLOADERRORS=$((DOWNLOADERRORS+1)) RETRYTIMEOUT=$(($RETRYTIMEOUT+5)) @@ -85,9 +85,14 @@ puts_verbose "ENV_DIR = $ENV_DIR" # Creating directories# Ensure directories exists mkdir -p "$BUILD_DIR/.profile.d" +if [[ ! -v DT_TECHNOLOGY ]]; then + puts_warn "No technology specified, falling back to 'all'" + DT_TECHNOLOGY="all" +fi + # Compile OneAgent Download URL DT_API_URL="${DT_API_URL:-https://$DT_TENANT.live.dynatrace.com/api}" -DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?&arch=x86}" +DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?&arch=x86&include=${DT_TECHNOLOGY}}" DT_DOWNLOAD_HEADER="Authorization: Api-Token ${DT_API_TOKEN}" puts_verbose "DT_TENANT=$DT_TENANT" From 04228d6156c602985f3743a861643012cbbd0056 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 21 Oct 2024 13:41:38 +0200 Subject: [PATCH 2/5] enable failing on unset variables and subshell errors --- bin/compile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index a82a9dd..9b3720a 100644 --- a/bin/compile +++ b/bin/compile @@ -1,8 +1,7 @@ #!/usr/bin/env bash # bin/compile -set -e # fail fast -# set -x # enable debugging +set -eu -o pipefail # Configure directories BUILD_DIR=$1 From 8fdce5a8679e59202e683c1b89a6bebf42920551 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 21 Oct 2024 13:50:04 +0200 Subject: [PATCH 3/5] disable failing on unset variables again for now, because it causes issues with the stdlib --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 9b3720a..adcc104 100644 --- a/bin/compile +++ b/bin/compile @@ -1,7 +1,7 @@ #!/usr/bin/env bash # bin/compile -set -eu -o pipefail +set -e -o pipefail # Configure directories BUILD_DIR=$1 From 07efacaef62943a53e95ea9659db4cfe82c7ada3 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 21 Oct 2024 14:19:22 +0200 Subject: [PATCH 4/5] updates subshell invocations to the more modern version, also minor quoting fixes --- bin/compile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/compile b/bin/compile index adcc104..e76e896 100644 --- a/bin/compile +++ b/bin/compile @@ -7,7 +7,7 @@ set -e -o pipefail BUILD_DIR=$1 CACHE_DIR=$2 ENV_DIR=$3 -BP_DIR=`cd $(dirname $0); cd ..; pwd` +BP_DIR="$(cd "$(dirname "$0")"; cd ..; pwd)" PROFILE_PATH="$BUILD_DIR/.profile.d/dynatrace.sh" EXPORT_PATH=/dev/null @@ -69,7 +69,7 @@ downloadAgent() { fi } -export_env $ENV_DIR '^(DT_|SSL_MODE|SKIP_ERRORS|BUILDPACK_)' '' +export_env "$ENV_DIR" '^(DT_|SSL_MODE|SKIP_ERRORS|BUILDPACK_)' '' # DT_TENANT and DT_API_TOKEN must be set if [ -z "${DT_TENANT}" ] || [ -z "${DT_API_TOKEN}" ]; then @@ -116,11 +116,11 @@ puts_step "Configuring Dynatrace Oneagent..." # determine default values for connection parameters DT_MANIFEST="$BUILD_DIR/dynatrace/oneagent/manifest.json" -MANIFEST_TENANT=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantUUID"])' <$DT_MANIFEST) -MANIFEST_TOKEN=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantToken"])' <$DT_MANIFEST) -MANIFEST_ENDPOINTS=$(python3 -c 'import sys, json; print(";".join(json.load(sys.stdin)["communicationEndpoints"]))' <$DT_MANIFEST) +MANIFEST_TENANT="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantUUID"])' <$DT_MANIFEST)" +MANIFEST_TOKEN="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantToken"])' <$DT_MANIFEST)" +MANIFEST_ENDPOINTS="$(python3 -c 'import sys, json; print(";".join(json.load(sys.stdin)["communicationEndpoints"]))' <$DT_MANIFEST)" -VERSION=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])' <$DT_MANIFEST) +VERSION="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])' <$DT_MANIFEST)" # support pipelined deployments by overriding default values set_env "DT_TENANT" "\${DT_TENANT:-$MANIFEST_TENANT}" From 26f2936c32d287277bebe9c9525a330c1c8a8689 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 21 Oct 2024 14:43:17 +0200 Subject: [PATCH 5/5] updates README with information about DT_TECHNOLOGY --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a3b4a5a..ca2cd29 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ The Dynatrace buildpack supports the following configurations: | DT_TAGS | *Optional* - The tags you want to add to the monitored apps. | | DT_NETWORK_ZONE | *Optional* - To look for communication endpoints located on the indicated region. | | SKIP_ERRORS | *Optional* - If set to 1, app deployment won't fail on agent installer download errors | +| DT_TECHNOLOGY | *Optional* - Configure specific OneAgent codemodules. This will potentially decrease the required disk space a lot. Falls back to `all` when not set, therefore including all suported technologies. Supported values can be found on https://docs.dynatrace.com/docs/dynatrace-api/environment-api/deployment/oneagent/download-oneagent-version#parameters in the "include" row | ## License