Skip to content

Commit 6c240c5

Browse files
committed
Merge remote-tracking branch 'origin/master' into glopes/sidecar-ffi-tel-metrics
2 parents 1d00e73 + 01cc88c commit 6c240c5

File tree

292 files changed

+81964
-1327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+81964
-1327
lines changed

.github/workflows/prof_asan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
php-version: [8.3, 8.4]
1212
container:
13-
image: datadog/dd-trace-ci:php-${{matrix.php-version}}_bookworm-5
13+
image: datadog/dd-trace-ci:php-${{matrix.php-version}}_bookworm-6
1414
# https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
1515
options: --user root --privileged
1616

.github/workflows/prof_correctness.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ jobs:
102102
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocations_1byte/test.pprof
103103
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
104104
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
105+
mkdir -p profiling/tests/correctness/allocations_1byte_no_zend_alloc/
106+
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocations_1byte_no_zend_alloc/test.pprof
107+
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
108+
USE_ZEND_ALLOC=0 php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
105109
unset DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE
106110
107111
- name: Run ZTS tests
@@ -131,6 +135,12 @@ jobs:
131135
expected_json: profiling/tests/correctness/allocations.json
132136
pprof_path: profiling/tests/correctness/allocations_1byte/
133137

138+
- name: Check profiler correctness for allocations with 1 byte sampling distance and `USE_ZEND_ALLOC=0`
139+
uses: Datadog/prof-correctness/analyze@main
140+
with:
141+
expected_json: profiling/tests/correctness/allocations.json
142+
pprof_path: profiling/tests/correctness/allocations_1byte_no_zend_alloc/
143+
134144
- name: Check profiler correctness for time
135145
uses: Datadog/prof-correctness/analyze@main
136146
with:

.github/workflows/prune-stale.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prune
2+
on:
3+
schedule:
4+
- cron: '0 3 1 * *'
5+
workflow_dispatch:
6+
7+
jobs:
8+
prune:
9+
name: Prune
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
steps:
15+
- name: Prune
16+
uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
17+
with:
18+
days-before-stale: 180
19+
stale-pr-message: 'This pull request has been marked as stale because it has not had activity in the past half year. It will be closed in 7 days if no further activity occurs. Feel free to reopen it if you are still working on it.'
20+
close-pr-message: 'This pull request has been closed because it has not had activity over the past half year. Feel free to reopen it if you are still working on it.'
21+
stale-issue-message: 'This issue has been marked as stale because it has not had activity in the past half year. It will be closed in 7 days if no further activity occurs. Feel free to reopen it if you are still working on it.'
22+
close-issue-message: 'This issue has been closed because it has not had activity over the past half year. Feel free to reopen it if you are still working on it.'
23+
stale-pr-label: 'tag: stale'
24+
operations-per-run: 50

.gitlab/collect_artifacts.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ mkdir -p "${CI_PROJECT_DIR}/artifacts/core_dumps"
66
find . -type f -name "core*" -exec head -c 4 "{}" \; -exec echo " {}" \; | grep -a ^.ELF | cut -d' ' -f2 | xargs -I % -n 1 cp % "${CI_PROJECT_DIR}/artifacts/core_dumps" || true
77
mkdir -p "${CI_PROJECT_DIR}/artifacts/diffs"
88
find . -type f -name '*.diff' -not -path "*/vendor/*" -exec cp --parents '{}' "${CI_PROJECT_DIR}/artifacts/diffs" \; || true
9+
mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
10+
find . -type f -name '*.xml' -path "*/artifacts/tests/*" -exec cp '{}' "${CI_PROJECT_DIR}/artifacts/tests/" \; || true

.gitlab/dockerhub-login.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
export VAULT_VERSION="1.20.0"
6+
7+
echo "=== Setting up Docker Hub authentication ==="
8+
9+
# Determine architecture for binary downloads
10+
arch="$(uname -m)"
11+
case "${arch}" in
12+
x86_64)
13+
vault_arch="amd64"
14+
;;
15+
aarch64|arm64)
16+
vault_arch="arm64"
17+
;;
18+
*)
19+
echo "Warning: Unsupported architecture: ${arch}. Skipping Docker Hub authentication." >&2
20+
exit 0
21+
;;
22+
esac
23+
24+
# Install jq if not already available
25+
if ! command -v jq > /dev/null 2>&1; then
26+
echo "Installing jq..."
27+
28+
jq_path="/tmp/jq"
29+
30+
if ! curl -L --fail "https://github.com/jqlang/jq/releases/latest/download/jq-linux-${vault_arch}" \
31+
--output "${jq_path}"; then
32+
echo "Warning: Failed to download jq. Skipping Docker Hub authentication." >&2
33+
exit 0
34+
fi
35+
36+
chmod +x "${jq_path}"
37+
export PATH="/tmp:${PATH}"
38+
fi
39+
40+
# Install Vault if not already available
41+
vault_cmd="vault"
42+
if ! command -v vault > /dev/null 2>&1; then
43+
echo "Installing Vault CLI..."
44+
45+
vault_path="/tmp/vault"
46+
vault_zip="${vault_path}.zip"
47+
48+
if ! curl -L --fail "https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_${vault_arch}.zip" \
49+
--output "${vault_zip}"; then
50+
echo "Warning: Failed to download Vault. Skipping Docker Hub authentication." >&2
51+
exit 0
52+
fi
53+
54+
if ! unzip -q "${vault_zip}" -d /tmp; then
55+
echo "Warning: Failed to extract Vault. Skipping Docker Hub authentication." >&2
56+
exit 0
57+
fi
58+
59+
chmod +x "${vault_path}"
60+
rm -f "${vault_zip}"
61+
62+
vault_cmd="${vault_path}"
63+
fi
64+
65+
# Fetch Docker Hub credentials from Vault
66+
echo "Fetching Docker Hub credentials from Vault..."
67+
vaultoutput="$("${vault_cmd}" kv get --format=json kv/k8s/gitlab-runner/dd-trace-php/dockerhub)" || {
68+
echo "Warning: Failed to fetch Docker Hub credentials from Vault. Skipping Docker Hub authentication." >&2
69+
exit 0
70+
}
71+
72+
user="$(echo "$vaultoutput" | jq -r '.data.data.user')"
73+
token="$(echo "$vaultoutput" | jq -r '.data.data.token')"
74+
75+
if [ -z "${user}" ] || [ -z "${token}" ] || [ "${user}" = "null" ] || [ "${token}" = "null" ]; then
76+
echo "Warning: Docker Hub credentials are empty or invalid. Skipping Docker Hub authentication." >&2
77+
exit 0
78+
fi
79+
80+
echo "Docker Hub user: ${user}"
81+
echo "Logging in to Docker Hub..."
82+
if ! echo "${token}" | docker login -u "${user}" --password-stdin docker.io; then
83+
echo "Warning: Failed to login to Docker Hub. Continuing without authentication." >&2
84+
exit 0
85+
fi
86+
87+
echo "=== Docker Hub authentication successful ==="

.gitlab/generate-appsec.php

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,13 @@
6262
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
6363
before_script:
6464
<?php echo $ecrLoginSnippet, "\n"; ?>
65-
- |
66-
echo "Logging in to Docker Hub"
67-
if [ "$CI_REGISTRY_USER" = "" ]; then
68-
echo "Fetching Docker Hub credentials from vault"
69-
vaultoutput=$(vault kv get --format=json kv/k8s/gitlab-runner/dd-trace-php/dockerhub)
70-
user=$(echo "$vaultoutput" | jq -r .data.data.user)
71-
token=$(echo "$vaultoutput" | jq -r .data.data.token)
72-
else
73-
user="$CI_REGISTRY_USER"
74-
token="$CI_REGISTRY_TOKEN"
75-
fi
76-
77-
echo "Docker Hub user: $user"
78-
docker login -u "$user" -p "$token" docker.io
79-
- apt update && apt install -y default-jre
65+
<?php dockerhub_login() ?>
66+
- apt update && apt install -y openjdk-17-jre
8067

8168
"test appsec extension":
8269
stage: test
8370
extends: .appsec_test
84-
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-${PHP_MAJOR_MINOR}_bookworm-5
71+
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-${PHP_MAJOR_MINOR}_bookworm-6
8572
variables:
8673
KUBERNETES_CPU_REQUEST: 3
8774
KUBERNETES_MEMORY_REQUEST: 3Gi
@@ -141,8 +128,9 @@
141128
- test8.5-release-zts
142129
before_script:
143130
<?php echo $ecrLoginSnippet, "\n"; ?>
131+
<?php dockerhub_login() ?>
144132
script:
145-
- apt update && apt install -y default-jre
133+
- apt update && apt install -y openjdk-17-jre
146134
- find "$CI_PROJECT_DIR"/appsec/tests/integration/build || true
147135
- |
148136
cd appsec/tests/integration
@@ -154,6 +142,16 @@
154142

155143
TERM=dumb ./gradlew $targets --info -Pbuildscan --scan
156144
TERM=dumb ./gradlew saveCaches --info
145+
after_script:
146+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
147+
- find appsec/tests/integration/build/test-results -name "*.xml" -exec cp --parents '{}' "${CI_PROJECT_DIR}/artifacts/" \;
148+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:appsec"
149+
artifacts:
150+
reports:
151+
junit: "artifacts/**/test-results/**/TEST-*.xml"
152+
paths:
153+
- "artifacts/"
154+
when: "always"
157155
cache:
158156
- key: "appsec int test cache"
159157
paths:
@@ -162,7 +160,7 @@
162160
"appsec code coverage":
163161
stage: test
164162
extends: .appsec_test
165-
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-8.3_bookworm-5
163+
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-8.3_bookworm-6
166164
variables:
167165
KUBERNETES_CPU_REQUEST: 3
168166
KUBERNETES_MEMORY_REQUEST: 3Gi
@@ -265,7 +263,7 @@
265263
"appsec lint":
266264
stage: test
267265
extends: .appsec_test
268-
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-8.3_bookworm-5
266+
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-8.3_bookworm-6
269267
variables:
270268
KUBERNETES_CPU_REQUEST: 3
271269
KUBERNETES_MEMORY_REQUEST: 9Gi
@@ -287,7 +285,7 @@
287285
"test appsec helper asan":
288286
stage: test
289287
extends: .appsec_test
290-
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:bookworm-5
288+
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:bookworm-6
291289
variables:
292290
KUBERNETES_CPU_REQUEST: 3
293291
KUBERNETES_MEMORY_REQUEST: 3Gi
@@ -313,7 +311,7 @@
313311
#"fuzz appsec helper":
314312
# stage: test
315313
# extends: .appsec_test
316-
# image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:bookworm-5
314+
# image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:bookworm-6
317315
# variables:
318316
# KUBERNETES_CPU_REQUEST: 3
319317
# KUBERNETES_MEMORY_REQUEST: 5Gi
@@ -358,3 +356,52 @@
358356
# artifacts:
359357
# paths:
360358
# - appsec/fuzzer-coverage.html
359+
360+
"check libxml2 version":
361+
stage: test
362+
image: registry.ddbuild.io/images/mirror/python:3.12-slim-bullseye
363+
tags: [ "arch:amd64" ]
364+
needs: []
365+
allow_failure: true
366+
variables:
367+
GIT_SUBMODULE_STRATEGY: none
368+
script:
369+
- |
370+
python3 - <<'EOF'
371+
import urllib.request
372+
import json
373+
import re
374+
import sys
375+
376+
# Read local version
377+
with open("appsec/third_party/libxml2/VERSION") as f:
378+
local_version = f.read().strip()
379+
print(f"Local libxml2 version: {local_version}")
380+
381+
# Fetch latest version from GNOME GitLab
382+
url = "https://gitlab.gnome.org/api/v4/projects/GNOME%2Flibxml2/repository/tags?per_page=100&order_by=updated&sort=desc"
383+
with urllib.request.urlopen(url) as response:
384+
tags = json.load(response)
385+
386+
# Extract version numbers and find the latest
387+
versions = []
388+
for tag in tags:
389+
match = re.match(r"v(\d+\.\d+\.\d+)$", tag["name"])
390+
if match:
391+
versions.append(match.group(1))
392+
393+
# Sort by version number
394+
versions.sort(key=lambda v: tuple(map(int, v.split("."))))
395+
latest_version = versions[-1] if versions else None
396+
397+
print(f"Latest libxml2 version: {latest_version}")
398+
399+
if local_version != latest_version:
400+
print("ERROR: libxml2 version mismatch!")
401+
print(f"Local version: {local_version}")
402+
print(f"Latest version: {latest_version}")
403+
print("Please update appsec/third_party/libxml2 to the latest version.")
404+
sys.exit(1)
405+
406+
print("libxml2 version is up to date.")
407+
EOF

.gitlab/generate-common.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
function unset_dd_runner_env_vars() {
3333
?>
34-
3534
# DD env vars auto-added to GitLab runners for infra purposes
3635
- unset DD_SERVICE
3736
- unset DD_ENV
@@ -40,6 +39,12 @@ function unset_dd_runner_env_vars() {
4039
<?php
4140
}
4241

42+
function dockerhub_login() {
43+
?>
44+
- if command -v docker > /dev/null 2>&1; then .gitlab/dockerhub-login.sh; fi
45+
<?php
46+
}
47+
4348
?>
4449
default:
4550
retry:
@@ -50,7 +55,6 @@ function unset_dd_runner_env_vars() {
5055
- runner_system_failure
5156
- scheduler_failure
5257
- api_failure
53-
- script_failure
5458
- stuck_or_timeout_failure
5559
- job_execution_timeout
5660

@@ -139,10 +143,27 @@ function unset_dd_runner_env_vars() {
139143
ZOOKEEPER_TICK_TIME: 2000
140144
ALLOW_ANONYMOUS_LOGIN: "yes"
141145
ZOOKEEPER_ADMIN_ENABLE_SERVER: "false"
146+
KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=srvr,ruok"
142147

143148
kafka:
144149
name: registry.ddbuild.io/images/mirror/confluentinc/cp-kafka:7.8.0
145150
alias: kafka-integration
151+
entrypoint: ["/bin/bash"]
152+
command:
153+
- -c
154+
- |
155+
# Wait for Zookeeper to be ready before starting Kafka
156+
echo "Waiting for Zookeeper to be ready..."
157+
for i in $(seq 1 30); do
158+
if echo "ruok" | nc zookeeper 2181 2>/dev/null | grep -q "imok"; then
159+
echo "Zookeeper is ready, starting Kafka..."
160+
break
161+
fi
162+
echo "Waiting for Zookeeper... attempt $i/30"
163+
sleep 2
164+
done
165+
# Start Kafka with original entrypoint
166+
exec /etc/confluent/docker/run
146167
variables:
147168
KAFKA_BROKER_ID: 111
148169
KAFKA_CREATE_TOPICS: test-lowlevel:1:1,test-highlevel:1:1

0 commit comments

Comments
 (0)