diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d5f2fa4b3..1e1a1c52c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ * @DataDog/serverless-aws .github/chainguard/serverless-init-ci-publish.sts.yaml @DataDog/serverless -.github/publish-serverless-init-to-ghcr.yaml @DataDog/serverless +.github/workflows/publish-serverless-init-to-ghcr.yml @DataDog/serverless diff --git a/.github/workflows/nightly-serverless-init.yml b/.github/workflows/nightly-serverless-init.yml deleted file mode 100644 index 88cf0b1c5..000000000 --- a/.github/workflows/nightly-serverless-init.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: Nightly serverless-init build - -on: - schedule: - # 2 AM UTC (~9-10 PM ET), daily - - cron: "0 2 * * *" - workflow_dispatch: - -env: - IMAGE_NAME: datadog/datadog-lambda-extension/serverless-init - REGISTRY: ghcr.io - -jobs: - build-nightly: - runs-on: ubuntu-22.04 - permissions: - contents: read - packages: write - strategy: - matrix: - arrays: - - { dockerFile: "Dockerfile.serverless-init.build", isAlpine: "false", tagSuffix: "" } - - { dockerFile: "Dockerfile.serverless-init.alpine.build", isAlpine: "true", tagSuffix: "-alpine" } - name: "Nightly Build (isAlpine: ${{ matrix.arrays.isAlpine }})" - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - repository: DataDog/datadog-agent - ref: main - path: datadog-agent - - - name: Compute version tags - id: meta - run: | - STAMP=$(date -u +%Y%m%d) - SHORT_SHA=$(git -C datadog-agent rev-parse --short=8 HEAD) - AGENT_VERSION=$(grep -m 1 -E '^[0-9]+\.[0-9]+\.[0-9]+$' datadog-agent/CHANGELOG.rst) || { echo "ERROR: could not detect agent version from datadog-agent's CHANGELOG.rst"; exit 1; } - echo "stamp=${STAMP}" >> "$GITHUB_OUTPUT" - echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT" - echo "version=nightly-${STAMP}-${SHORT_SHA}" >> "$GITHUB_OUTPUT" - echo "agent_version=${AGENT_VERSION}" >> "$GITHUB_OUTPUT" - - # Pin QEMU to a known-good version. See release-serverless-init.yml - # and test-qemu-versions.yml for context on QEMU breakage history. - - name: Set up QEMU - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 - with: - image: tonistiigi/binfmt:qemu-v10.1.3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - - - name: Build binaries - working-directory: ./scripts - run: ./build_serverless_init.sh - env: - AGENT_PATH: datadog-agent - VERSION: ${{ steps.meta.outputs.version }} - AGENT_VERSION: ${{ steps.meta.outputs.agent_version }} - SERVERLESS_INIT: "true" - ALPINE: ${{ matrix.arrays.isAlpine }} - - - name: Set up build directory and copy binaries - run: cp -r .layers/. ./scripts/bin/ - - - name: Set up tracer installation script - run: cp ./scripts/serverless_init_dotnet.sh ./scripts/bin/ - - - name: Login to GHCR - uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 - with: - context: ./scripts - file: ./scripts/${{ matrix.arrays.dockerFile }} - push: true - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-main${{ matrix.arrays.tagSuffix }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main-${{ steps.meta.outputs.stamp }}-${{ steps.meta.outputs.short_sha }}${{ matrix.arrays.tagSuffix }} - provenance: false - platforms: linux/amd64,linux/arm64 - - retry: - needs: [build-nightly] - if: failure() && fromJSON(github.run_attempt) < 2 - runs-on: ubuntu-22.04 - permissions: - actions: write - steps: - - name: Retry failed action - env: - GH_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} - run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }} - - notify: - needs: [build-nightly] - if: failure() && fromJSON(github.run_attempt) >= 2 - runs-on: ubuntu-22.04 - steps: - - name: Notify Slack - env: - SLACK_CHANNEL: "#serverless-agent" - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - run: | - OPS_MESSAGE=":gh-check-failed: Nightly serverless-init build failed! - - The nightly build from datadog-agent main did not succeed after retry. - - See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for details." - - curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" \ - -d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$OPS_MESSAGE" '{channel: $channel, text: $text}')" diff --git a/.github/workflows/release-serverless-init.yml b/.github/workflows/release-serverless-init.yml deleted file mode 100644 index becfb872c..000000000 --- a/.github/workflows/release-serverless-init.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Release serverless-init - -on: - workflow_dispatch: - inputs: - buildTags: - type: choice - description: Build tags - default: "serverless otlp zlib zstd" - options: - - "serverless otlp zlib zstd" - - "serverless zlib zstd" - tag: - type: string - description: Docker image tag name, eg. (beta11, beta12-rc1, etc.) - latestTag: - type: choice - description: Additionally, tag this as latest? Only use this if releasing a new production version. - default: "no" - options: - - "yes" - - "no" - agentVersion: - type: string - description: Datadog agent version (default latest release tag from Datadog agent branch) - agentBranch: - type: string - description: Datadog agent branch or tag name (default main) - default: "main" - -env: - IMAGE_NAME: datadog/datadog-lambda-extension/serverless-init - REGISTRY: ghcr.io - -jobs: - release-serverless-init: - runs-on: ubuntu-22.04 - permissions: - packages: write - strategy: - matrix: - arrays: [ - {dockerFile: "Dockerfile.serverless-init.build", isAlpine: "false", tagSuffix: ""}, - {dockerFile: "Dockerfile.serverless-init.alpine.build", isAlpine: "true", tagSuffix: "-alpine"} - ] - name: "Release Serverless Init (isAlpine: ${{ matrix.arrays.isAlpine }})" - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - repository: DataDog/datadog-agent - ref: ${{ github.event.inputs.agentBranch }} - path: datadog-agent - - - name: Compute agent version - id: meta - run: | - AGENT_VERSION="${{ github.event.inputs.agentVersion }}" - if [ -z "$AGENT_VERSION" ]; then - AGENT_VERSION=$(grep -m 1 -E '^[0-9]+\.[0-9]+\.[0-9]+$' datadog-agent/CHANGELOG.rst) || { echo "ERROR: could not detect agent version from datadog-agent's CHANGELOG.rst; set the Datadog agent version manually"; exit 1; } - fi - echo "agent_version=${AGENT_VERSION}" >> "$GITHUB_OUTPUT" - - # Pin QEMU to a known-good version. The default (binfmt:latest) has broken - # arm64 emulation multiple times due to QEMU segfaults in libc-bin triggers: - # - Feb 2025: qemu-v9.2.0 — PR #571 pinned, PR #581 reverted to :latest - # - Mar 2026: qemu-v10.2.1 — binfmt:latest updated Feb 18, broke builds - # See .github/workflows/test-qemu-versions.yml to sweep versions before - # bumping this pin. A sweep pass is necessary but not sufficient — always - # verify with a real build, as some failures are load-dependent. - - name: Set up QEMU - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0 - with: - image: tonistiigi/binfmt:qemu-v10.1.3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - - - name: Build binaries - working-directory: ./scripts - run: ./build_serverless_init.sh - env: - AGENT_PATH: datadog-agent - VERSION: ${{ github.event.inputs.tag }} - SERVERLESS_INIT: true - ALPINE: ${{ matrix.arrays.isAlpine }} - AGENT_VERSION: ${{ steps.meta.outputs.agent_version }} - - - name: Set up build directory and copy binaries - run: | - cp -r .layers/. ./scripts/bin/ - - - name: Set up tracer installation script - run: | - cp ./scripts/serverless_init_dotnet.sh ./scripts/bin/ - - - name: Login to GHCR - uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 - with: - context: ./scripts - file: ./scripts/${{ matrix.arrays.dockerFile }} - push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.tag }}${{ matrix.arrays.tagSuffix }} - provenance: false - platforms: linux/amd64,linux/arm64 - - - name: Build and push latest - id: docker_build_latest - uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 - if: ${{ github.event.inputs.latestTag == 'yes' }} - with: - context: ./scripts - file: ./scripts/${{ matrix.arrays.dockerFile }} - push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest${{ matrix.arrays.tagSuffix }} - provenance: false - platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/serverless-init-vulnerability-scan.yml b/.github/workflows/serverless-init-vulnerability-scan.yml deleted file mode 100644 index abea921e9..000000000 --- a/.github/workflows/serverless-init-vulnerability-scan.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: "Serverless Init Vulnerability Scan" - -on: - schedule: - # daily at midnight - - cron: "0 0 * * *" - workflow_dispatch: - -env: - # adds public.ecr.aws as fallback incase rate limit on ghcr.io is hit - TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db - TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db - -jobs: - trivy-scans: - runs-on: ubuntu-22.04 - steps: - - name: Scan latest serverless-init image with trivy - uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0 - with: - image-ref: "datadog/serverless-init:latest" - ignore-unfixed: true - exit-code: 1 - format: table - - - name: Scan latest-alpine serverless-init image with trivy - uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0 - with: - image-ref: "datadog/serverless-init:latest-alpine" - ignore-unfixed: true - exit-code: 1 - format: table - - grype-scans: - runs-on: ubuntu-22.04 - steps: - - name: Scan latest serverless-init image with grype - uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0 - with: - image: "datadog/serverless-init:latest" - only-fixed: true - fail-build: true - severity-cutoff: low - output-format: table - - - name: Scan latest-alpine serverless-init image with grype - uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0 - with: - image: "datadog/serverless-init:latest-alpine" - only-fixed: true - fail-build: true - severity-cutoff: low - output-format: table - - retry: - needs: [trivy-scans, grype-scans] - if: failure() && fromJSON(github.run_attempt) < 2 - runs-on: ubuntu-22.04 - permissions: - actions: write - steps: - - name: Retry failed action - env: - GH_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} - run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }} - - notify: - needs: [trivy-scans, grype-scans] - if: failure() && fromJSON(github.run_attempt) >= 2 - runs-on: ubuntu-22.04 - steps: - - name: Notify - env: - SLACK_CHANNEL: "#serverless-agent" - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - run: | - set -x - - OPS_MESSAGE=":gh-check-failed: Serverless Init Vulnerability Scan failed! :radar-scan: - - Whoever is on support, please fix the vulnerability, before a customer alerts us to it. - - See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for the full info on the found vulnerability. :bufo-thanks:" - - curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{ - "channel": "'"$SLACK_CHANNEL"'", - "text": "'"$OPS_MESSAGE"'" - }' diff --git a/.github/workflows/test-qemu-versions.yml b/.github/workflows/test-qemu-versions.yml deleted file mode 100644 index 5bda19306..000000000 --- a/.github/workflows/test-qemu-versions.yml +++ /dev/null @@ -1,146 +0,0 @@ -# Test QEMU/binfmt versions for arm64 cross-compilation on x86_64 runners. -# -# The serverless-init release build (release-serverless-init.yml) uses QEMU via -# docker/setup-qemu-action to emulate arm64 during multi-platform Docker builds. -# The QEMU version provided by tonistiigi/binfmt:latest has broken arm64 emulation -# multiple times, causing segfaults during "Processing triggers for libc-bin" in -# the ubuntu:22.04 compresser stage of our Dockerfiles (Dockerfile.build and -# Dockerfile.alpine.build). Because of this, release-serverless-init.yml pins a -# specific binfmt image version rather than using :latest. -# -# History of QEMU breakage in this repo: -# -# Feb 2025 — qemu-v9.2.0 caused segfaults in arm64 emulation. -# - https://github.com/tonistiigi/binfmt/issues/240 -# - https://github.com/DataDog/datadog-agent/pull/33988 (pin in datadog-agent) -# - https://github.com/DataDog/datadog-lambda-extension/pull/571 (pin here) -# - https://github.com/DataDog/datadog-lambda-extension/pull/581 (reverted pin -# after upstream claimed fix — this left us on :latest for ~12 months) -# -# Mar 2026 — qemu-v10.2.1 (shipped in binfmt:latest on Feb 18 2026) caused the -# same segfault pattern. The last successful build was Feb 17 2026, one day -# before the new image was published. This time we pin permanently. -# -# Test results (Mar 2026, two runs to check for flakiness): -# -# Version | Run 1 | Run 2 | Notes -# --------------|-------|-------|------ -# qemu-v10.2.1 | pass | pass | Passes simple tests but FAILS in real build -# qemu-v10.1.3 | pass | pass | Current pin target -# qemu-v10.0.4 | pass | pass | -# qemu-v9.2.2 | pass | pass | Has QEMU-side fix (actions/runner-images#11662) -# qemu-v9.2.0 | FAIL | FAIL | Consistently broken -# qemu-v8.1.5 | FAIL | FAIL | Consistently broken -# qemu-v8.1.4 | FAIL | pass | Flaky -# qemu-v8.0.4 | pass | pass | -# qemu-v7.0.0-28| pass | pass | Long-standing known-good baseline -# -# Important caveats: -# - Some versions are non-deterministically broken (v8.1.4 flipped between runs). -# - v10.2.1 passes all tests here but segfaults in the real build, likely because -# the real build runs Go compilation and the compresser stage concurrently under -# QEMU, creating enough load to trigger the flaky segfault. -# - Therefore: a version passing this sweep is necessary but NOT sufficient. -# Always verify with an actual release build before merging a pin change. -# -# Relevant upstream issues: -# - https://github.com/tonistiigi/binfmt/issues/215 -# - https://github.com/tonistiigi/binfmt/issues/240 -# - https://github.com/tonistiigi/binfmt/issues/245 -# - https://github.com/actions/runner-images/issues/11662 -# -# Usage: -# 1. Dispatch this workflow from the Actions tab to sweep all versions. -# 2. Run it twice to check for flakiness. -# 3. Pick the newest consistently passing version. -# 4. Update the pin in release-serverless-init.yml. -# 5. Do a real serverless-init release build to confirm before merging. - -name: Test QEMU versions for arm64 emulation - -on: - workflow_dispatch: - -jobs: - test-qemu: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - qemu_image: - # v10.x - - "tonistiigi/binfmt:qemu-v10.2.1" - - "tonistiigi/binfmt:qemu-v10.1.3" - - "tonistiigi/binfmt:qemu-v10.0.4" - # v9.x - - "tonistiigi/binfmt:qemu-v9.2.2" - - "tonistiigi/binfmt:qemu-v9.2.0" - # v8.x - - "tonistiigi/binfmt:qemu-v8.1.5" - - "tonistiigi/binfmt:qemu-v8.1.4" - - "tonistiigi/binfmt:qemu-v8.0.4" - # v7.x - - "tonistiigi/binfmt:qemu-v7.0.0-28" - name: "QEMU ${{ matrix.qemu_image }}" - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0 - with: - image: ${{ matrix.qemu_image }} - - - name: Show QEMU version - run: docker run --rm --privileged ${{ matrix.qemu_image }} --version - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - - # Simple docker run tests — catches deterministically broken versions - # (v9.2.0 and v8.1.5 consistently fail here; v8.1.4 is flaky). - - name: "Test: docker run - ubuntu:22.04 apt-get (simple)" - run: | - docker run --rm --platform linux/arm64 ubuntu:22.04 \ - bash -c "apt-get update && apt-get install -y zip binutils && echo 'SUCCESS: docker run apt-get completed'" - - - name: "Test: docker run - alpine:3.16 apk add (simple)" - run: | - docker run --rm --platform linux/arm64 alpine:3.16 \ - sh -c "apk add --no-cache git make musl-dev gcc && echo 'SUCCESS: docker run apk completed'" - - # Buildx tests — closer to the real build, using docker buildx build with - # Dockerfiles that match the stages in Dockerfile.build and Dockerfile.alpine.build. - # Note: even these may not catch load-dependent failures; see header comment. - - name: "Test: buildx - compresser stage (matches real Dockerfile.build)" - run: | - cat > /tmp/Dockerfile.test-compresser <<'DOCKERFILE' - FROM ubuntu:22.04 as compresser - RUN apt-get update && apt-get install -y zip binutils - RUN mkdir /extensions - WORKDIR /extensions - RUN echo "SUCCESS: buildx compresser stage completed" - DOCKERFILE - docker buildx build --platform linux/arm64 -f /tmp/Dockerfile.test-compresser /tmp - - - name: "Test: buildx - alpine builder stage (matches real Dockerfile.alpine.build)" - run: | - cat > /tmp/Dockerfile.test-alpine <<'DOCKERFILE' - FROM alpine:3.16 as builder - RUN apk add --no-cache git make musl-dev gcc - COPY --from=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 echo "SUCCESS: buildx alpine builder stage completed" - DOCKERFILE - docker buildx build --platform linux/arm64 -f /tmp/Dockerfile.test-alpine /tmp - - - name: "Test: buildx - multi-platform (both arches, matches real build)" - run: | - cat > /tmp/Dockerfile.test-multi <<'DOCKERFILE' - FROM ubuntu:22.04 - RUN apt-get update && apt-get install -y zip binutils - RUN echo "SUCCESS: buildx multi-platform completed" - DOCKERFILE - docker buildx build --platform linux/amd64,linux/arm64 -f /tmp/Dockerfile.test-multi /tmp diff --git a/.gitignore b/.gitignore index 5f37fbf77..79c2d7c7c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,8 +21,6 @@ local_tests/java/build/ local_tests/java/lib/ local_tests/java/out/ local_tests/java/.gradle/ -local_tests/serverless-init/datadog-agent -local_tests/serverless-init/logs.txt bottlecap/target bottlecap/proptest-regressions diff --git a/README.md b/README.md index 309ea2604..699bdcb76 100644 --- a/README.md +++ b/README.md @@ -99,33 +99,9 @@ You can also open an issue for a feature request. If you find an issue with this package and have a fix, please feel free to open a pull request following the [procedures](https://github.com/DataDog/datadog-agent/blob/main/docs/public/guidelines/contributing.md). -## Testing +## Serverless-Init -To test a change to the Datadog Serverless-Init in Google Cloud Run: - -1. Clone this repo and [the Datadog Agent repo](https://github.com/DataDog/datadog-agent) into the same parent directory. -2. Run `VERSION=0 SERVERLESS_INIT=true ./scripts/build_binary_and_layer_dockerized.sh` in this repo to build the serverless-init binary. -3. Create a "Hello World" serverless application [as described here](https://cloud.google.com/run/docs/quickstarts/build-and-deploy/go). -4. Follow [the public instructions](https://docs.datadoghq.com/serverless/google_cloud_run) to add the Serverless-Init to your serverless application. -5. Copy the binary file that you built to the same location as your Dockerfile: - -``` -cp datadog-lambda-extension/.layers/datadog_extension-amd64/extensions/datadog-agent ~/hello-world-app/datadog-init -``` - -6. In your Dockerfile, replace - -``` -COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init -``` - -with - -``` -COPY datadog-init /app/datadog-init -``` - -Deploy your serverless application, and it will run with a version of the Serverless-Init that includes your changes to the code. +Serverless-Init CI/CD has been moved to its own repository. See [serverless-init-ci](https://gitlab.ddbuild.io/DataDog/serverless-init-ci) for building, testing, and releasing serverless-init images. ## Community diff --git a/local_tests/serverless-init/app.py b/local_tests/serverless-init/app.py deleted file mode 100644 index 2d9b44cb6..000000000 --- a/local_tests/serverless-init/app.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import urllib.request -from threading import Thread -from flask import Flask, Response - -app = Flask(__name__) - - -@app.route("/") -def home(): - return Response("{\"msg\":\"Hello!\"}", status=200, mimetype='application/json') - - -app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080))) diff --git a/local_tests/serverless-init/build-docker-runtime.sh b/local_tests/serverless-init/build-docker-runtime.sh deleted file mode 100755 index 7b453b278..000000000 --- a/local_tests/serverless-init/build-docker-runtime.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# ./build-docker-runtime.sh && ./invoke.sh 2 - -set -e - -if [ -z $RUNTIME ]; then - echo "Runtime not specified, using python 39" - RUNTIME=python -fi - -# Determine architecture, M1 requires arm64 while Intel chip requires amd64. If testing with docker on M1, use amd64 -if [ -z "$ARCHITECTURE" ]; then - if [ $(uname -m) == "arm64" ]; then - ARCHITECTURE=arm64 - else - ARCHITECTURE=amd64 - fi -fi - -DOCKERFILE=serverless-init-python.Dockerfile - -CURRENT_PATH=$(pwd) -SCRIPTS_ROOT=$(dirname "$(dirname "$CURRENT_PATH")") - -# Build the extension -SERVERLESS_INIT=true ARCHITECTURE=$ARCHITECTURE VERSION=1 $SCRIPTS_ROOT/scripts/build_binary_and_layer_dockerized.sh - -# Copy the newly built extension in the same folder as the Dockerfile -cp $SCRIPTS_ROOT/.layers/datadog_extension-$ARCHITECTURE/extensions/datadog-agent . - -# Build the recorder extension which will act as a man-in-a-middle to intercept payloads sent to Datadog -cd $SCRIPTS_ROOT/../datadog-agent/test/integration/serverless - -ARCHITECTURE=$ARCHITECTURE ./build_recorder.sh -echo "Extracting recordering-extension executable into $SCRIPTS_ROOT/local_tests" -unzip -j -o ./recorder-extension/ext.zip "extensions/recorder-extension" -d $SCRIPTS_ROOT/local_tests - -cd - - -# Build the image -docker build --platform=linux/$ARCHITECTURE -t datadog/extension-local-tests --no-cache -f $DOCKERFILE . diff --git a/local_tests/serverless-init/invoke.sh b/local_tests/serverless-init/invoke.sh deleted file mode 100755 index 0f4abc943..000000000 --- a/local_tests/serverless-init/invoke.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -N_INVOKE=$1 - -# Start the container -dockerId=$(docker run -d -p 127.0.0.1:9000:8080 -p 127.0.0.1:8124:8124 datadog/extension-local-tests) - -i=0 -while true; do - i=$((i + 1)) - echo "Invoke # $i" - curl -XGET "http://localhost:9000" - echo - sleep 1 - if [[ $i -ge $N_INVOKE ]]; then - echo "Saving logs to logs.txt" - docker logs $dockerId >logs.txt 2>&1 - echo "Stopping" - docker stop $dockerId - exit 0 - fi - sleep 1 -done diff --git a/local_tests/serverless-init/requirements.txt b/local_tests/serverless-init/requirements.txt deleted file mode 100644 index e1660629e..000000000 --- a/local_tests/serverless-init/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Flask==2.1.2 -ddtrace==1.4.1 -Werkzeug==2.2.2 \ No newline at end of file diff --git a/local_tests/serverless-init/serverless-init-python.Dockerfile b/local_tests/serverless-init/serverless-init-python.Dockerfile deleted file mode 100644 index aaee70581..000000000 --- a/local_tests/serverless-init/serverless-init-python.Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM debian:11-slim AS build -RUN apt-get update && \ - apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \ - python3 -m venv /venv && \ - /venv/bin/pip install --upgrade pip setuptools wheel - -FROM build AS build-venv -COPY requirements.txt /requirements.txt -RUN /venv/bin/pip install --disable-pip-version-check -r /requirements.txt - -FROM gcr.io/distroless/python3-debian11 - -COPY --from=build-venv /venv /venv - -COPY datadog-agent /app/datadog-init - -COPY app.py /app/app.py - -WORKDIR /app - -ENV PYTHONUNBUFFERED=1 -ENV DD_SERVICE=self-monitoring -ENV DD_VERSION=1 -ENV DD_LOGS_ENABLED=true -ENV DD_API_KEY=DONT_CARE - -ENTRYPOINT ["/app/datadog-init"] -CMD ["/venv/bin/ddtrace-run", "/venv/bin/python3", "app.py"] diff --git a/scripts/Dockerfile.serverless-init.alpine.build b/scripts/Dockerfile.serverless-init.alpine.build deleted file mode 100644 index e4eeeac2e..000000000 --- a/scripts/Dockerfile.serverless-init.alpine.build +++ /dev/null @@ -1,4 +0,0 @@ -FROM scratch -ARG TARGETARCH - -COPY ./bin/datadog_extension-$TARGETARCH-alpine/extensions/datadog-agent /datadog-init diff --git a/scripts/Dockerfile.serverless-init.build b/scripts/Dockerfile.serverless-init.build deleted file mode 100644 index e40cad4d9..000000000 --- a/scripts/Dockerfile.serverless-init.build +++ /dev/null @@ -1,8 +0,0 @@ -FROM gcr.io/distroless/cc-debian12 -COPY --from=busybox:1.37-uclibc /bin/sh /bin/sh -ARG TARGETARCH - -COPY ./bin/datadog_extension-$TARGETARCH/extensions/datadog-agent /datadog-init -COPY ./bin/serverless_init_dotnet.sh /dotnet.sh - -ENTRYPOINT ["/datadog-init"] diff --git a/scripts/build_binary_and_layer_dockerized.sh b/scripts/build_binary_and_layer_dockerized.sh index 1b3135c3a..01fb39150 100755 --- a/scripts/build_binary_and_layer_dockerized.sh +++ b/scripts/build_binary_and_layer_dockerized.sh @@ -19,18 +19,10 @@ if [ -z "$VERSION" ]; then exit 1 fi -if [ -z "$SERVERLESS_INIT" ]; then - CMD_PATH="cmd/serverless" -else - CMD_PATH="cmd/serverless-init" -fi +CMD_PATH="cmd/serverless" if [ -z "$BUILD_TAGS" ]; then - if [ -z "$SERVERLESS_INIT" ]; then - BUILD_TAGS="serverless otlp" - else - BUILD_TAGS="serverless otlp zlib zstd" - fi + BUILD_TAGS="serverless otlp" fi if [ -z "$AGENT_PATH" ]; then @@ -84,16 +76,7 @@ function docker_build_zip { unzip $TARGET_DIR/datadog_extension-${arch}${suffix}.zip -d $TARGET_DIR/datadog_extension-${arch}${suffix} } -if [[ "$SERVERLESS_INIT" == "true" && "$ALPINE" == "false" ]]; then - echo "Building serverless init for non-alpine amd64 & arm64" - docker_build_zip amd64 - docker_build_zip arm64 -elif [[ "$SERVERLESS_INIT" == "true" && "$ALPINE" == "true" ]]; then - echo "Building serverless init for alpine amd64 & arm64" - BUILD_FILE=Dockerfile.alpine.build - docker_build_zip amd64 -alpine - docker_build_zip arm64 -alpine -elif [ "$ARCHITECTURE" == "amd64" ]; then +if [ "$ARCHITECTURE" == "amd64" ]; then echo "Building for amd64 only" docker_build_zip amd64 BUILD_FILE=Dockerfile.alpine.build diff --git a/scripts/build_serverless_init.sh b/scripts/build_serverless_init.sh deleted file mode 100755 index 5f5f7cae0..000000000 --- a/scripts/build_serverless_init.sh +++ /dev/null @@ -1,20 +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 2021 Datadog, Inc. - -# Usage: AGENT_VERSION=7.43.0 VERSION=5 ALPINE=false ./scripts/build_serverless_init.sh -# the ALPINE var indicates whether or not alpine or non-alpine images will be built. - -# Optional environment variables: -# VERSION - Use a specific version number - -set -e - -# Move into the root directory -SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd $SCRIPTS_DIR/.. - -AGENT_VERSION=$AGENT_VERSION VERSION=$VERSION SERVERLESS_INIT=true ALPINE=$ALPINE ./scripts/build_binary_and_layer_dockerized.sh diff --git a/scripts/serverless_init_dotnet.sh b/scripts/serverless_init_dotnet.sh deleted file mode 100644 index 3dc96f357..000000000 --- a/scripts/serverless_init_dotnet.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -# Check if Alpine -if [ -f "/etc/alpine-release" ]; then - echo "Alpine images are not supported for .NET automatic instrumentation with serverless-init" - exit 1 -fi - -# Make sure curl and jq are installed -apt-get update && apt-get install -y curl jq - -ghcurl() { - if [ -n "$GITHUB_TOKEN" ]; then - echo "Github token provided" >&2 - curl -sSL -w '{"status_code": %{http_code}}' -H "Authorization: Bearer $GITHUB_TOKEN" "$@" | jq -sre add - else - echo "Github token not provided" >&2 - curl -sSL -w '{"status_code": %{http_code}}' "$@" | jq -sre add - fi -} - -# Get latest released version of dd-trace-dotnet -response=$(ghcurl https://api.github.com/repos/DataDog/dd-trace-dotnet/releases/latest) -sanitized_response=$(echo "$response" | tr -d '\000-\037') # remove control characters from json response -echo "Status code of version request: $(echo "$sanitized_response" | jq '.status_code')" -TRACER_VERSION=$(echo "$sanitized_response" | jq -r '.tag_name // empty' | sed 's/^v//') - -if [ -z "$TRACER_VERSION" ]; then - echo "Error: Could not determine the tracer version. Exiting." >&2 - exit 1 -fi - -# Download the tracer to the dd_tracer folder -echo Downloading version "${TRACER_VERSION}" of the .NET tracer into /tmp/datadog-dotnet-apm.tar.gz -response=$(ghcurl "https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm-${TRACER_VERSION}.tar.gz" \ - -o /tmp/datadog-dotnet-apm.tar.gz) -echo "Status code of download request: $(echo "$response" | jq '.status_code')" - -# Unarchive the tracer and remove the tmp -mkdir -p /dd_tracer/dotnet -tar -xzf /tmp/datadog-dotnet-apm.tar.gz -C /dd_tracer/dotnet -rm /tmp/datadog-dotnet-apm.tar.gz - -# Create Log path -/dd_tracer/dotnet/createLogPath.sh