Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 18 additions & 4 deletions utils/build/docker/cpp_kong/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,10 +98,12 @@ 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" \
https://github.com/DataDog/kong-plugin-ddtrace.git kong-plugin-ddtrace
TAG=$(get_latest_release "DataDog/kong-plugin-ddtrace")
echo "Installing kong-plugin-ddtrace from latest release ${TAG}"
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

# ---------------------------------------------------------------------------
Expand All @@ -108,6 +112,16 @@ fi
PLUGIN_VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' \
kong-plugin-ddtrace/kong/plugins/ddtrace/handler.lua)

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" \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use checked-out plugin commit for dev version suffix

load-binary.sh now supports LIBRARY_TARGET_BRANCH for cpp_kong, but the version suffix logic here always reads DataDog/kong-plugin-ddtrace/commits/main, so the emitted SYSTEM_TESTS_LIBRARY_VERSION can point to a different revision than the plugin actually copied into the image whenever a non-main branch is tested (or main moves between clone and build). That mislabels build metadata and can misattribute experiment results during triage.

Useful? React with 👍 / 👎.

| 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
printf '{"status":"ok","library":{"name":"cpp_kong","version":"%s"}}' \
"$PLUGIN_VERSION" > /builds/healthcheck.json
Expand Down
16 changes: 5 additions & 11 deletions utils/scripts/load-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,11 @@ 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
Comment on lines +314 to +315

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle existing kong-plugin-ddtrace checkout before cloning

The new cpp_kong path always executes git clone ... kong-plugin-ddtrace, but there is no cleanup/update path when that directory already exists from a previous run. In that local workflow (for example, rerunning with a different LIBRARY_TARGET_BRANCH), git clone fails with destination path 'kong-plugin-ddtrace' already exists and is not an empty directory, so the script cannot refresh the binary without manual directory deletion.

Useful? React with 👍 / 👎.

Comment on lines +314 to +315

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear old rock artifacts before cloning cpp_kong

This new clone path does not remove existing kong-plugin-ddtrace*.rock files from prior runs, and install_ddtrace.sh still prioritizes .rock artifacts over kong-plugin-ddtrace/ when both are present. In that common rerun scenario, the build silently uses the stale rock instead of the freshly cloned branch, so tests run against unintended plugin code.

Useful? React with 👍 / 👎.

echo "Using kong-plugin-ddtrace@$(git -C kong-plugin-ddtrace rev-parse --short HEAD)"

elif [ "$TARGET" = "cpp_nginx" ]; then
assert_version_is_dev
Expand Down
Loading