From d6209bf2a8f289569d2a211ea4807d4bba5d3b8e Mon Sep 17 00:00:00 2001 From: Tianning Li Date: Mon, 2 Mar 2026 11:25:09 -0500 Subject: [PATCH] chore(ci): remove Go agent build artifacts and variables Delete compile_go_agent.sh and Go agent Dockerfiles which are no longer needed since the extension was rewritten in Rust. Remove the now-orphaned AGENT_BRANCH and AGENT_VERSION pipeline input variables from .gitlab-ci.yml. --- .gitlab-ci.yml | 6 - .gitlab/scripts/compile_go_agent.sh | 116 ------------------ bottlecap/Cargo.lock | 2 +- .../src/lifecycle/invocation/processor.rs | 5 +- images/Dockerfile.go_agent.alpine.compile | 80 ------------ images/Dockerfile.go_agent.compile | 81 ------------ 6 files changed, 5 insertions(+), 285 deletions(-) delete mode 100755 .gitlab/scripts/compile_go_agent.sh delete mode 100644 images/Dockerfile.go_agent.alpine.compile delete mode 100644 images/Dockerfile.go_agent.compile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d77bfce3..8dbc4f9fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,12 +5,6 @@ variables: # This will be overwritten by the tag version if it is a release. VERSION: dev # Manual trigger variables - AGENT_BRANCH: - description: "Branch of the datadog-agent repository to use." - value: main - AGENT_VERSION: - description: "Latest release version of the datadog-agent to tag the build with." - value: "7.66.0" PIPELINE_LAYER_SUFFIX: description: "Suffix to be appended to the layer name (default empty)." value: "" diff --git a/.gitlab/scripts/compile_go_agent.sh b/.gitlab/scripts/compile_go_agent.sh deleted file mode 100755 index 124c709e1..000000000 --- a/.gitlab/scripts/compile_go_agent.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash - -# Unless explicitly stated otherwise all files in this repository are licensed -# under the Apache License Version 2.0. -# This product includes software developed at Datadog (https://www.datadoghq.com/). -# Copyright 2024 Datadog, Inc. - -set -e - -if [ -z "$ARCHITECTURE" ]; then - printf "[ERROR]: ARCHITECTURE not specified\n" - exit 1 -fi - -if [ -z "$FILE_SUFFIX" ]; then - printf "[WARNING] No FILE_SUFFIX provided, using ${ARCHITECTURE}\n" - FILE_SUFFIX=$ARCHITECTURE -fi - -if [ -z "$AGENT_VERSION" ]; then - printf "[ERROR]: AGENT_VERSION not specified\n" - exit 1 -else - printf "Compiling agent with version: ${AGENT_VERSION}\n" -fi - -if [ -z "$ALPINE" ]; then - printf "[ERROR]: ALPINE not specified\n" - exit 1 -else - printf "Alpine compile requested: ${ALPINE}\n" -fi - -if [ -z "$FIPS" ]; then - printf "[ERROR]: FIPS not specified\n" - exit 1 -else - printf "Fips compile requested: ${FIPS}\n" -fi - -if [ -z "$CI_COMMIT_TAG" ]; then - # Running on dev - printf "Running on dev environment\n" - VERSION="dev" -else - printf "Found version tag in environment\n" - VERSION="${CI_COMMIT_TAG//[!0-9]/}" - printf "Version: ${VERSION}\n" -fi - - -if [ "$ALPINE" = "0" ]; then - COMPILE_IMAGE=Dockerfile.go_agent.compile -else - printf "Compiling for alpine\n" - COMPILE_IMAGE=Dockerfile.go_agent.alpine.compile -fi - -if [ -z "$SUFFIX" ]; then - printf "No suffix provided, using ${ARCHITECTURE}\n" - SUFFIX=$ARCHITECTURE -fi - -# Allow override build tags -if [ -z "$BUILD_TAGS" ]; then - if [ "$FIPS" = "0" ]; then - BUILD_TAGS="serverless otlp" - else - BUILD_TAGS="serverless otlp serverlessfips" - fi -fi - -# Allow override agent path -if [ -z "$AGENT_PATH" ]; then - AGENT_PATH="../datadog-agent" -fi - -MAIN_DIR=$(pwd) # datadog-lambda-extension - -BINARY_DIR=".binaries" -TARGET_DIR=$MAIN_DIR/$BINARY_DIR -BINARY_PATH=$TARGET_DIR/compiled-datadog-agent-$FILE_SUFFIX - -mkdir -p $BINARY_DIR - -# Prepare folder with only *mod and *sum files to enable Docker caching capabilities -mkdir -p $MAIN_DIR/scripts/.src $MAIN_DIR/scripts/.cache -printf "Copy mod files to build a cache\n" -cp $AGENT_PATH/go.mod $MAIN_DIR/scripts/.cache -cp $AGENT_PATH/go.sum $MAIN_DIR/scripts/.cache - -# Compress all files to speed up docker copy -touch $MAIN_DIR/scripts/.src/datadog-agent.tgz -cd $AGENT_PATH/.. -tar --exclude=.git -czf $MAIN_DIR/scripts/.src/datadog-agent.tgz datadog-agent -cd $MAIN_DIR - -function docker_compile { - arch=$1 - file=$2 - - docker buildx build --platform linux/${arch} \ - -t datadog/compile-go-agent:${VERSION} \ - -f ${MAIN_DIR}/images/${file} \ - --build-arg EXTENSION_VERSION="${VERSION}" \ - --build-arg AGENT_VERSION="${AGENT_VERSION}" \ - --build-arg BUILD_TAGS="${BUILD_TAGS}" \ - --build-arg FIPS="${FIPS}" \ - . -o $BINARY_PATH - - # Copy the compiled binary to the target directory with the expected name - # If it already exist, it will be replaced - cp $BINARY_PATH/datadog-agent $TARGET_DIR/datadog-agent-$FILE_SUFFIX -} - -docker_compile $ARCHITECTURE $COMPILE_IMAGE diff --git a/bottlecap/Cargo.lock b/bottlecap/Cargo.lock index 41a6272da..bb6f5d25d 100644 --- a/bottlecap/Cargo.lock +++ b/bottlecap/Cargo.lock @@ -525,7 +525,7 @@ dependencies = [ "tokio", "tokio-util", "tonic-types", - "tower 0.5.3", + "tower", "tower-http", "tracing", "tracing-core", diff --git a/bottlecap/src/lifecycle/invocation/processor.rs b/bottlecap/src/lifecycle/invocation/processor.rs index ccb9f497e..e369e5238 100644 --- a/bottlecap/src/lifecycle/invocation/processor.rs +++ b/bottlecap/src/lifecycle/invocation/processor.rs @@ -285,7 +285,10 @@ impl Processor { /// This is used to create a cold start span, since this telemetry event does not /// provide a `request_id`, we try to guess which invocation is the cold start. pub fn on_platform_init_start(&mut self, time: DateTime, runtime_version: Option) { - if runtime_version.as_deref().map_or(false, |rv| rv.contains("DurableFunction")) { + if runtime_version + .as_deref() + .is_some_and(|rv| rv.contains("DurableFunction")) + { self.enhanced_metrics.set_durable_function_tag(); } let start_time: i64 = SystemTime::from(time) diff --git a/images/Dockerfile.go_agent.alpine.compile b/images/Dockerfile.go_agent.alpine.compile deleted file mode 100644 index ac8e6b125..000000000 --- a/images/Dockerfile.go_agent.alpine.compile +++ /dev/null @@ -1,80 +0,0 @@ -FROM registry.ddbuild.io/images/mirror/alpine:3.16 AS compiler -ARG EXTENSION_VERSION -ARG AGENT_VERSION -ARG BUILD_TAGS -ARG CGO_ENABLED -ARG GOEXPERIMENT -ARG FIPS - -# Install dependencies -RUN apk add --no-cache git make musl-dev gcc - -# NOTE: the version of go specifed here is used to get the base go tooling for -# our builds. The actual version that we use for building the agent is the one -# listed in the agen't go.work files. The go we install here will download the -# appropriate version specified in the go.work file before running go commands -# for the agent. -COPY --from=registry.ddbuild.io/images/mirror/golang:1.24.6-alpine /usr/local/go/ /usr/lib/go - -ENV GOROOT=/usr/lib/go -ENV GOPATH=/go -ENV PATH=/go/bin:$PATH - -RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin -RUN mkdir -p /tmp/dd/datadog-agent - -# Copy cached dependencies -COPY ./scripts/.cache/go.mod /tmp/dd/datadog-agent -COPY ./scripts/.cache/go.sum /tmp/dd/datadog-agent -WORKDIR /tmp/dd/datadog-agent - -# Add and unzip agent tarball -ADD ./scripts/.src/datadog-agent.tgz /tmp/dd - -# Build the Serverless Go Agent -# -# Sets the `EXTENSION_VERSION` to the serverless tags. -# Also sets the `AGENT_VERSION` to the version of the agent. -WORKDIR /tmp/dd/datadog-agent/cmd/serverless - -RUN --mount=type=cache,target=/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ - if [ "$FIPS" = "1" ]; then \ - export CGO_ENABLED=1; \ - export GOEXPERIMENT=boringcrypto; \ - fi; \ - echo CGO_ENABLED=$CGO_ENABLED; \ - echo GOEXPERIMENT=$GOEXPERIMENT; \ - if [ -z "$AGENT_VERSION" ]; then \ - /usr/lib/go/bin/go build -ldflags="-w -extldflags '-static' \ - -X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \ - -tags "${BUILD_TAGS}" -o datadog-agent; \ - else \ - /usr/lib/go/bin/go build -ldflags="-w -extldflags '-static' \ - -X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \ - -X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \ - -tags "${BUILD_TAGS}" -o datadog-agent; \ - fi - -# Ensure that the `agentVersionDefault` variable exists in the binary. -RUN /usr/lib/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \ - (echo "agentVersionDefault variable doesn't exist" && exit 1) - -RUN if [ "$FIPS" = "1" ]; then \ - /usr/lib/go/bin/go tool nm datadog-agent | grep -i 'crypto/internal/boring/sig.FIPSOnly' || \ - (echo "boringcrypto not enabled" && exit 1); \ - else \ - /usr/lib/go/bin/go tool nm datadog-agent | grep -i 'crypto/internal/boring/sig.FIPSOnly'; \ - if [ $? -eq 0 ]; then \ - echo "boringcrypto incorrectly enabled"; \ - exit 1; \ - fi; \ - fi - -# Strip the binary to reduce size -RUN strip datadog-agent - -# Use the smallest image possible -FROM scratch -COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent / -ENTRYPOINT ["/datadog-agent"] diff --git a/images/Dockerfile.go_agent.compile b/images/Dockerfile.go_agent.compile deleted file mode 100644 index 6a0f3d56d..000000000 --- a/images/Dockerfile.go_agent.compile +++ /dev/null @@ -1,81 +0,0 @@ -FROM public.ecr.aws/lambda/provided:al2 AS compiler -ARG EXTENSION_VERSION -ARG AGENT_VERSION -ARG BUILD_TAGS -ARG FIPS - -RUN mkdir -p /tmp/dd/datadog-agent - -# Install dependencies -RUN yum install -y wget tar gzip gcc - -# NOTE: the version of go specifed here is used to get the base go tooling for -# our builds. The actual version that we use for building the agent is the one -# listed in the agen't go.work files. The go we install here will download the -# appropriate version specified in the go.work file before running go commands -# for the agent. -RUN arch="$(uname -m)"; \ - if [ "${arch}" = 'aarch64' ]; then \ - arch='arm64'; \ - fi; \ - if [ "${arch}" = 'x86_64' ]; then \ - arch='amd64'; \ - fi; \ - wget -O go1.24.6.linux-${arch}.tar.gz https://go.dev/dl/go1.24.6.linux-${arch}.tar.gz; \ - tar -C /usr/local -xzf go1.24.6.linux-${arch}.tar.gz - -# Copy cached dependencies -COPY ./scripts/.cache/go.mod /tmp/dd/datadog-agent -COPY ./scripts/.cache/go.sum /tmp/dd/datadog-agent -WORKDIR /tmp/dd/datadog-agent - -# Add and unzip agent tarball -ADD ./scripts/.src/datadog-agent.tgz /tmp/dd - -# Build the Serverless Go Agent -# -# Sets the `EXTENSION_VERSION` to the serverless tags. -# Also sets the `AGENT_VERSION` to the version of the agent. -WORKDIR /tmp/dd/datadog-agent/cmd/serverless - -RUN --mount=type=cache,target=/root/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ - if [ "$FIPS" = "1" ]; then \ - export CGO_ENABLED=1; \ - export GOEXPERIMENT=boringcrypto; \ - fi; \ - echo CGO_ENABLED=$CGO_ENABLED; \ - echo GOEXPERIMENT=$GOEXPERIMENT; \ - if [ -z "$AGENT_VERSION" ]; then \ - /usr/local/go/bin/go build -ldflags="-w \ - -X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \ - -tags "${BUILD_TAGS}" -o datadog-agent; \ - else \ - /usr/local/go/bin/go build -ldflags="-w \ - -X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \ - -X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \ - -tags "${BUILD_TAGS}" -o datadog-agent; \ - fi - -# Ensure that the `agentVersionDefault` variable exists in the binary. -RUN /usr/local/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \ - (echo "agentVersionDefault variable doesn't exist" && exit 1) - -RUN if [ "$FIPS" = "1" ]; then \ - /usr/local/go/bin/go tool nm datadog-agent | grep -i 'crypto/internal/boring/sig.FIPSOnly' || \ - (echo "boringcrypto not enabled" && exit 1); \ - else \ - /usr/local/go/bin/go tool nm datadog-agent | grep -i 'crypto/internal/boring/sig.FIPSOnly'; \ - if [ $? -eq 0 ]; then \ - echo "boringcrypto incorrectly enabled"; \ - exit 1; \ - fi; \ - fi - -# Strip the binary to reduce size -RUN strip datadog-agent - -# Use the smallest image possible -FROM scratch -COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent / -ENTRYPOINT ["/datadog-agent"]