Skip to content

Commit 9a9525e

Browse files
authored
Improve and simplify the microbenchmarks CI setup (#7613)
- [x] Revert [a7749d8](a7749d8) before merging. ## Summary of changes - Restore changes from the now-reverted #7571 PR. - Fixes the dd-octo-sts GitHub token setup by creating a token targeting benchmarking-platform instead of dd-trace-dotnet when running benchmarks. - Corresponding dd-octo-sts policy on benchmarking-platform: https://github.com/DataDog/benchmarking-platform/blob/main/.github/chainguard/gitlab.github-access.read-contents.sts.yaml ## Reason for change - We couldn't clone benchmarking-platform from ephemeral benchmarking instances with the dd-octo-sts setup introduced on #7571. ## Implementation details ## Test coverage Test run on the CI: https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-dotnet/-/jobs/1161521230 ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. -->
1 parent 32e3725 commit 9a9525e

File tree

3 files changed

+122
-78
lines changed

3 files changed

+122
-78
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
issuer: https://gitlab.ddbuild.io
2+
3+
subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-dotnet:ref_type:(branch|tag):ref:.*"
4+
5+
permissions:
6+
contents: read

.gitlab/benchmarks/macrobenchmarks.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@ profiler_cpu_timer_create-arm64:
467467
- platform/artifacts/
468468
expire_in: 3 months
469469
variables:
470+
AWS_REGION: "us-east-1"
471+
472+
# Branch containing 1. scripts to launch Windows benchmarks on ephemeral
473+
# instances (to be used by GitLab CI runners) and 2. scripts to run Windows
474+
# benchmarks (to be used by the ephemeral instances).
475+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "dd-trace-dotnet/macro"
476+
470477
# Whether to cleanup ephemeral instances after benchmarks are run
471478
CLEANUP: "true"
472479

@@ -489,14 +496,17 @@ profiler_cpu_timer_create-arm64:
489496
script:
490497
- source build-id.txt
491498
- echo "Building for the following build https://dev.azure.com/datadoghq/dd-trace-dotnet/_build/results?buildId=$buildId&view=results"
492-
- export BP_INFRA_BENCHMARKING_PLATFORM_BRANCH=dd-trace-dotnet/macro
493499
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform && cd platform
494500
- ./ephemeral-infra/run-windows-benchmarks.sh
495501
after_script:
496502
- |
497-
bp-infra cleanup --provision ./platform/ephemeral-infra/provisions/macrobenchmark-ephemeral-instance.yaml \
498-
--region "${AWS_REGION}" \
499-
--bypass-stack-destroy
503+
if [ "$CLEANUP" == "true" ]; then
504+
bp-infra cleanup --provision ./platform/ephemeral-infra/provisions/macrobenchmark-ephemeral-instance.yaml \
505+
--region "${AWS_REGION}" \
506+
--bypass-stack-destroy
507+
else
508+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
509+
fi
500510
501511
baseline-win:
502512
extends: .benchmarks-win
Lines changed: 102 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,129 @@
1-
.setup:
2-
script:
3-
- mkdir -p ~/.aws
4-
- /app/bp-infra/tools/fetch-ssm-parameter.sh $AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER > ~/.aws/config || exit $?
5-
- export AWS_PROFILE=ephemeral-infra-ci
6-
- export BP_INFRA_KEY_PAIR_NAME=$(cat ~/.aws/key-pair-name.txt)
7-
- export BP_INFRA_KEY_PAIR_PRIVATE_KEY_PATH=~/.aws/key-pair-private-key.pem
1+
.dd-octo-sts-setup:
2+
before_script:
3+
- |
4+
set +e
5+
echo "Attempting to retrieve a GitHub token for scope '$DDOCTOSTS_SCOPE' with policy '$DDOCTOSTS_POLICY' with dd-octo-sts..."
6+
error_output=$({ dd-octo-sts token --scope $DDOCTOSTS_SCOPE --policy $DDOCTOSTS_POLICY > "/tmp/github-token"; } 2>&1)
7+
exit_code=$?
8+
if [ $exit_code -ne 0 ]; then
9+
echo "ERROR: Failed to retrieve GitHub token."
10+
echo "Original error: $error_output"
11+
echo "Continuing execution anyway..."
12+
fi
13+
set -e
814
915
stages:
10-
- infra-update
16+
- build
1117
- benchmarks
1218

13-
update-bp-infra:
14-
stage: infra-update
19+
build-dd-trace-dotnet-microbenchmarks-ami:
20+
stage: build
21+
tags: ["arch:amd64"]
1522
timeout: 3h
16-
tags: ["arch:amd64"]
1723
allow_failure: true
18-
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
24+
when: manual
1925
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dd-trace-dotnet-micro
26+
id_tokens:
27+
DDOCTOSTS_ID_TOKEN:
28+
aud: dd-octo-sts
29+
variables:
30+
# Allows ephemeral instances to read content from dd-trace-dotnet
31+
# This is not strictly necessary in the current AMI build
32+
DDOCTOSTS_SCOPE: "DataDog/dd-trace-dotnet"
33+
DDOCTOSTS_POLICY: "gitlab.github-access.read-contents"
34+
35+
AWS_REGION: "us-east-1"
36+
37+
# TODO: Point to dd-trace-dotnet/micro after the branch below is merged
38+
# to it
39+
# Branch containing a provision for building the AMI
40+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "augusto/dd-trace-dotnet-micro-bp-ui"
41+
42+
PROVISION_FILE: "platform/ephemeral-infra/ami.yaml"
43+
44+
# Where AMI creation artifacts will be stored
45+
BP_INFRA_ARTIFACTS_BUCKET_NAME: "windows-benchmarking-results-us-east-1"
2046

47+
# Whether to cleanup instances after building the AMI, since the AMI is
48+
# based on an instance that is created in this job
49+
CLEANUP: "true"
50+
before_script:
51+
- !reference [.dd-octo-sts-setup, before_script]
2152
script:
22-
- git clone --branch dd-trace-dotnet/micro https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
23-
- mkdir -p ~/.aws
24-
- /app/bp-infra/tools/fetch-ssm-parameter.sh $AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER >> ~/.aws/config || exit $?
25-
- aws ssm get-parameter --region "$AWS_REGION" --name "ci.${CI_PROJECT_NAME}.ephemeral-infra-ci.windows-benchmarking-key-pair-name" --with-decryption --query "Parameter.Value" --out text >> ~/.aws/key-pair-name.txt
26-
- aws ssm get-parameter --region "$AWS_REGION" --name "ci.${CI_PROJECT_NAME}.ephemeral-infra-ci.windows-benchmarking-key-private-key" --with-decryption --query "Parameter.Value" --out text >> ~/.aws/key-pair-private-key.pem
27-
- export AWS_PROFILE=ephemeral-infra-ci
28-
- export BP_INFRA_KEY_PAIR_NAME=$(cat ~/.aws/key-pair-name.txt)
29-
- export BP_INFRA_KEY_PAIR_PRIVATE_KEY_PATH=~/.aws/key-pair-private-key.pem
30-
- bp-infra launch --provision ./platform/ephemeral-infra/base-instance.yaml --region "${AWS_REGION}" --bypass-stack-destroy
53+
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
54+
- echo "GITHUB_TOKEN=$(cat /tmp/github-token)" > .env
55+
- CLEANUP_ARG=$([[ "$CLEANUP" == "false" ]] && echo "--no-cleanup" || echo "")
56+
- |
57+
bp-infra launch --region "${AWS_REGION}" --os "windows" \
58+
--provision "${PROVISION_FILE}" \
59+
--bypass-stack-destroy \
60+
--env .env \
61+
$CLEANUP_ARG
3162
after_script:
32-
- !reference [.setup, script]
63+
# Makes sure the instance is cleaned up.
64+
# Note: This does not clean up the created AMI.
3365
- |
34-
bp-infra cleanup --provision ./platform/ephemeral-infra/base-instance.yaml \
35-
--region "${AWS_REGION}" \
36-
--bypass-stack-destroy
37-
38-
rules:
39-
- when: manual
40-
variables:
41-
AWS_REGION: "us-east-1"
42-
CLEANUP: "false"
43-
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
44-
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
45-
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
46-
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"
66+
if [ "$CLEANUP" == "true" ]; then
67+
bp-infra cleanup --region "${AWS_REGION}" --os "windows" \
68+
--provision "${PROVISION_FILE}" \
69+
--bypass-stack-destroy
70+
else
71+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
72+
fi
4773
4874
run-benchmarks:
4975
stage: benchmarks
5076
tags: ["arch:amd64"]
5177
timeout: 2h
5278
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
5379
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dd-trace-dotnet-micro
54-
55-
script:
56-
- git clone --branch dd-trace-dotnet/micro https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
57-
- AWS_REGION=${AWS_REGION} ./platform/steps/launch-instance.sh
58-
after_script:
59-
- |
60-
bp-infra cleanup --provision ./platform/ephemeral-infra/ephemeral-instance-main.yaml \
61-
--region "${AWS_REGION}" \
62-
--bypass-stack-destroy
63-
- ./platform/steps/post-pr-comment.sh
64-
# Temporarily commented out pending issue resolution with sending files to backend
65-
# - ./platform/steps/upload-to-bp-ui.sh
66-
80+
id_tokens:
81+
DDOCTOSTS_ID_TOKEN:
82+
aud: dd-octo-sts
6783
rules:
6884
- when: on_success
69-
variables:
70-
AWS_REGION: "us-east-1"
71-
72-
upload-to-bp-ui:
73-
stage: benchmarks
74-
tags: ["arch:amd64"]
75-
timeout: 1h
76-
# Image created in the following job https://gitlab.ddbuild.io/DataDog/benchmarking-platform-tools/-/jobs/869830045
77-
image: registry.ddbuild.io/images/benchmarking-platform-tools-ubuntu:dotnet-microbenchmarks
78-
79-
script:
80-
- git clone --branch fayssal/test-micro-delivery https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
81-
# - ./platform/steps/launch-instance.sh
82-
# - ./platform/steps/post-pr-comment.sh
83-
# Temporarely commented out pending issue resolution with sending files to backend
84-
- ./platform/steps/upload-to-bp-ui.sh
85-
8685
artifacts:
8786
name: "artifacts"
8887
when: always
8988
paths:
90-
- candidate-results/
89+
- platform/artifacts
9190
expire_in: 3 months
92-
93-
rules:
94-
- when: manual
9591
variables:
92+
# Allows ephemeral instances to read content from benchmarking-platform
93+
DDOCTOSTS_SCOPE: "DataDog/benchmarking-platform"
94+
DDOCTOSTS_POLICY: "gitlab.github-access.read-contents"
95+
9696
AWS_REGION: "us-east-1"
97-
CLEANUP: "false"
98-
AWS_EPHEMERAL_INFRA_PROFILE_SSM_PARAMETER: "ci.dd-trace-dotnet.ephemeral-infra-ci.dd-trace-dotnet-profile"
99-
AWS_EPHEMERAL_INFRA_PROFILE_NAME: "ephemeral-infra-ci"
100-
AWS_EPHEMERAL_INFRA_ARTIFACTS_BUCKET_URI: "s3://windows-benchmarking-results/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_JOB_ID"
101-
AWS_EPHEMERAL_INFRA_REGION: "us-east-1"
97+
98+
# TODO: Point to dd-trace-dotnet/micro after the branch below is merged
99+
# to it
100+
# Branch containing 1. scripts to launch Windows benchmarks on ephemeral
101+
# instances (to be used by GitLab CI runners) and 2. scripts to run Windows
102+
# benchmarks (to be used by the ephemeral instances).
103+
BP_INFRA_BENCHMARKING_PLATFORM_BRANCH: "augusto/dd-trace-dotnet-micro-bp-ui"
104+
105+
# Where benchmarking results will be stored
106+
BP_INFRA_ARTIFACTS_BUCKET_NAME: "windows-benchmarking-results-us-east-1"
107+
108+
# Whether to cleanup ephemeral instances after benchmarks are run
109+
CLEANUP: "true"
110+
111+
# Where to look for benchmarking artifacts for uploading to the BP UI
112+
ARTIFACTS_DIR: "platform/artifacts"
113+
before_script:
114+
- !reference [.dd-octo-sts-setup, before_script]
115+
script:
116+
- export GITHUB_TOKEN=$(cat /tmp/github-token)
117+
- git clone --branch $BP_INFRA_BENCHMARKING_PLATFORM_BRANCH https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform
118+
- ./platform/steps/run-windows-benchmarks.sh
119+
after_script:
120+
- |
121+
if [ "$CLEANUP" == "true" ]; then
122+
bp-infra cleanup --provision ./platform/ephemeral-infra/instance.yaml \
123+
--region "${AWS_REGION}" \
124+
--bypass-stack-destroy
125+
else
126+
echo "'CLEANUP' is set to 'false'. Will not cleanup."
127+
fi
128+
- ./platform/steps/post-pr-comment.sh
129+
- ./platform/steps/upload-to-bp-ui.sh

0 commit comments

Comments
 (0)