From 19dfb1b0b5db4b0587bf58581a9920c3fb748d6e Mon Sep 17 00:00:00 2001 From: Adesh Kumar Date: Mon, 2 Mar 2026 14:27:26 -0500 Subject: [PATCH 1/2] cpp_kong: use latest release as fallback, dev version from main --- utils/build/docker/cpp_kong/install_ddtrace.sh | 11 ++++++++--- utils/scripts/load-binary.sh | 18 +++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/utils/build/docker/cpp_kong/install_ddtrace.sh b/utils/build/docker/cpp_kong/install_ddtrace.sh index 70676b30b54..d24a1aff238 100755 --- a/utils/build/docker/cpp_kong/install_ddtrace.sh +++ b/utils/build/docker/cpp_kong/install_ddtrace.sh @@ -96,9 +96,9 @@ elif [ -d kong-plugin-ddtrace ]; then echo "Using Kong plugin from binaries/kong-plugin-ddtrace" else - KONG_PLUGIN_BRANCH="${KONG_PLUGIN_BRANCH:-main}" - echo "Cloning kong-plugin-ddtrace branch ${KONG_PLUGIN_BRANCH}" - git clone --depth 1 --branch "$KONG_PLUGIN_BRANCH" \ + TAG=$(get_latest_release "DataDog/kong-plugin-ddtrace") + echo "Installing kong-plugin-ddtrace from latest release ${TAG}" + git clone --depth 1 --branch "$TAG" \ https://github.com/DataDog/kong-plugin-ddtrace.git kong-plugin-ddtrace fi @@ -108,6 +108,11 @@ fi PLUGIN_VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' \ kong-plugin-ddtrace/kong/plugins/ddtrace/handler.lua) +if [ -f kong-plugin-ddtrace/dev_commit ]; then + COMMIT_SHA=$(cat kong-plugin-ddtrace/dev_commit) + PLUGIN_VERSION="${PLUGIN_VERSION}-dev+${COMMIT_SHA}" +fi + echo "${PLUGIN_VERSION}" > /builds/SYSTEM_TESTS_LIBRARY_VERSION printf '{"status":"ok","library":{"name":"cpp_kong","version":"%s"}}' \ "$PLUGIN_VERSION" > /builds/healthcheck.json diff --git a/utils/scripts/load-binary.sh b/utils/scripts/load-binary.sh index a0bc211ba2d..5b4bbfa0498 100755 --- a/utils/scripts/load-binary.sh +++ b/utils/scripts/load-binary.sh @@ -309,17 +309,13 @@ elif [ "$TARGET" = "cpp_httpd" ]; then elif [ "$TARGET" = "cpp_kong" ]; then assert_version_is_dev - assert_target_branch_is_not_set - RELEASE=$(curl --silent --fail --show-error -H "Authorization: token $GITHUB_TOKEN" \ - "https://api.github.com/repos/DataDog/kong-plugin-ddtrace/releases/tags/tip") - ASSET_NAME=$(echo "$RELEASE" | jq -r '.assets[] | select(.name | test("kong-plugin-ddtrace.*\\.rock")) | .name') - ASSET_URL=$(echo "$RELEASE" | jq -r '.assets[] | select(.name | test("kong-plugin-ddtrace.*\\.rock")) | .url') - echo "Downloading $ASSET_NAME from kong-plugin-ddtrace tip release" - curl --silent --fail --show-error -L \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/octet-stream" \ - --output "$ASSET_NAME" \ - "$ASSET_URL" + LIBRARY_TARGET_BRANCH="${LIBRARY_TARGET_BRANCH:-main}" + echo "Cloning kong-plugin-ddtrace branch ${LIBRARY_TARGET_BRANCH}" + git clone --depth 1 --branch "$LIBRARY_TARGET_BRANCH" \ + https://github.com/DataDog/kong-plugin-ddtrace.git kong-plugin-ddtrace + COMMIT_SHA=$(git -C kong-plugin-ddtrace rev-parse --short HEAD) + echo "$COMMIT_SHA" > kong-plugin-ddtrace/dev_commit + echo "Using kong-plugin-ddtrace@${COMMIT_SHA}" elif [ "$TARGET" = "cpp_nginx" ]; then assert_version_is_dev From f0c89d3ebfc325e2e6c2cbc86e36d10683ec446b Mon Sep 17 00:00:00 2001 From: Adesh Kumar Date: Tue, 3 Mar 2026 10:38:00 -0500 Subject: [PATCH 2/2] fetch commit SHA from Github for dev version --- .../build/docker/cpp_kong/install_ddtrace.sh | 19 ++++++++++++++----- utils/scripts/load-binary.sh | 4 +--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/utils/build/docker/cpp_kong/install_ddtrace.sh b/utils/build/docker/cpp_kong/install_ddtrace.sh index d24a1aff238..375f20cca3e 100755 --- a/utils/build/docker/cpp_kong/install_ddtrace.sh +++ b/utils/build/docker/cpp_kong/install_ddtrace.sh @@ -65,6 +65,8 @@ fi # --------------------------------------------------------------------------- # 2. Get Kong plugin files # --------------------------------------------------------------------------- +KONG_IS_RELEASE=false + rock_file="" for f in kong-plugin-ddtrace*.rock; do if [ -e "$f" ]; then @@ -98,8 +100,10 @@ elif [ -d kong-plugin-ddtrace ]; then else TAG=$(get_latest_release "DataDog/kong-plugin-ddtrace") echo "Installing kong-plugin-ddtrace from latest release ${TAG}" - git clone --depth 1 --branch "$TAG" \ - https://github.com/DataDog/kong-plugin-ddtrace.git kong-plugin-ddtrace + curl -sL "https://github.com/DataDog/kong-plugin-ddtrace/archive/refs/tags/${TAG}.tar.gz" \ + | tar -xz + mv "kong-plugin-ddtrace-${TAG#v}" kong-plugin-ddtrace + KONG_IS_RELEASE=true fi # --------------------------------------------------------------------------- @@ -108,9 +112,14 @@ fi PLUGIN_VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' \ kong-plugin-ddtrace/kong/plugins/ddtrace/handler.lua) -if [ -f kong-plugin-ddtrace/dev_commit ]; then - COMMIT_SHA=$(cat kong-plugin-ddtrace/dev_commit) - PLUGIN_VERSION="${PLUGIN_VERSION}-dev+${COMMIT_SHA}" +if [ "$KONG_IS_RELEASE" = "false" ]; then + auth_header=$(get_authentication_header) + COMMIT_SHA=$(eval "curl --silent --fail --retry 3 $auth_header \ + https://api.github.com/repos/DataDog/kong-plugin-ddtrace/commits/main" \ + | grep '"sha"' | head -1 | cut -d'"' -f4 | cut -c1-7) + if [ -n "$COMMIT_SHA" ]; then + PLUGIN_VERSION="${PLUGIN_VERSION}-dev+${COMMIT_SHA}" + fi fi echo "${PLUGIN_VERSION}" > /builds/SYSTEM_TESTS_LIBRARY_VERSION diff --git a/utils/scripts/load-binary.sh b/utils/scripts/load-binary.sh index 5b4bbfa0498..26613c1a054 100755 --- a/utils/scripts/load-binary.sh +++ b/utils/scripts/load-binary.sh @@ -313,9 +313,7 @@ elif [ "$TARGET" = "cpp_kong" ]; then echo "Cloning kong-plugin-ddtrace branch ${LIBRARY_TARGET_BRANCH}" git clone --depth 1 --branch "$LIBRARY_TARGET_BRANCH" \ https://github.com/DataDog/kong-plugin-ddtrace.git kong-plugin-ddtrace - COMMIT_SHA=$(git -C kong-plugin-ddtrace rev-parse --short HEAD) - echo "$COMMIT_SHA" > kong-plugin-ddtrace/dev_commit - echo "Using kong-plugin-ddtrace@${COMMIT_SHA}" + echo "Using kong-plugin-ddtrace@$(git -C kong-plugin-ddtrace rev-parse --short HEAD)" elif [ "$TARGET" = "cpp_nginx" ]; then assert_version_is_dev