Skip to content

Commit 149c406

Browse files
committed
Merge branch 'main' into bump-apm-perf
2 parents e22e642 + c12fad8 commit 149c406

File tree

153 files changed

+19474
-4107
lines changed

Some content is hidden

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

153 files changed

+19474
-4107
lines changed

.buildkite/hooks/pre-command

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,8 @@
1010

1111
set -eo pipefail
1212

13-
retry() {
14-
local retries=$1
15-
shift
16-
17-
local count=0
18-
until "$@"; do
19-
exit=$?
20-
wait=$((2 ** count))
21-
count=$((count + 1))
22-
if [ $count -lt "$retries" ]; then
23-
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
24-
sleep $wait
25-
else
26-
>&2 echo "Retry $count/$retries exited $exit, no more retries left."
27-
return $exit
28-
fi
29-
done
30-
return 0
31-
}
13+
# shellcheck disable=SC1091
14+
source .buildkite/scripts/utils.sh
3215

3316
get_os_details() {
3417
case $(uname | tr '[:upper:]' '[:lower:]') in
@@ -93,7 +76,7 @@ GH_TOKEN="${VAULT_GITHUB_TOKEN}"
9376
export GH_TOKEN
9477

9578
echo "--- Setting up the :golang: environment..."
96-
GO_VERSION=$(cat .go-version)
79+
GO_VERSION=$(grep '^go' go.mod | cut -d' ' -f2)
9780
WORKSPACE=$(git rev-parse --show-toplevel)
9881
export GO_VERSION WORKSPACE
9982
get_os_details

.buildkite/scripts/dra.sh

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ set -eo pipefail
1313
# Either staging or snapshot
1414
TYPE="$1"
1515

16-
## Read current version without the qualifier
17-
VERSION=$(make get-version-only)
16+
# NOTE: load the shared functions
17+
# shellcheck disable=SC1091
18+
source .buildkite/scripts/utils.sh
1819

1920
echo "--- Restoring Artifacts"
2021
buildkite-agent artifact download "build/**/*" .
@@ -34,48 +35,26 @@ fi
3435
# by default it uses the buildkite branch
3536
DRA_BRANCH="$BUILDKITE_BRANCH"
3637
# by default it publishes the DRA artifacts, for such it uses the collect command.
37-
dra_command=collect
38+
DRA_COMMAND=collect
39+
VERSION=$(make get-version-only)
3840
BRANCHES_URL=https://storage.googleapis.com/artifacts-api/snapshots/branches.json
3941
curl -s "${BRANCHES_URL}" > active-branches.json
40-
# as long as `8.x` is not in the active branches, we will explicitly add the condition.
41-
if [ "$BUILDKITE_BRANCH" == "8.x" ] || grep -q "\"$BUILDKITE_BRANCH\"" active-branches.json ; then
42-
echo "--- :arrow_right: Release Manager only supports the current active branches and 8.x, running"
43-
else
42+
if ! grep -q "\"$BUILDKITE_BRANCH\"" active-branches.json ; then
4443
# If no active branches are found, let's see if it is a feature branch.
45-
echo "--- :arrow_right: Release Manager only supports the current active branches, skipping"
46-
echo "BUILDKITE_BRANCH=$BUILDKITE_BRANCH"
47-
echo "BUILDKITE_COMMIT=$BUILDKITE_COMMIT"
48-
echo "VERSION=$VERSION"
49-
echo "Supported branches:"
50-
cat active-branches.json
51-
if [[ $BUILDKITE_BRANCH =~ "feature/" ]]; then
52-
buildkite-agent annotate "${BUILDKITE_BRANCH} will list DRA artifacts. Feature branches are not supported. Look for the supported branches in ${BRANCHES_URL}" --style 'info' --context 'ctx-info'
53-
dra_command=list
54-
55-
# use a different branch since DRA does not support feature branches but main/release branches
56-
# for such we will use the VERSION and https://storage.googleapis.com/artifacts-api/snapshots/<major.minor>.json
57-
# to know if the branch was branched out from main or the release branches.
58-
MAJOR_MINOR=${VERSION%.*}
59-
if curl -s "https://storage.googleapis.com/artifacts-api/snapshots/main.json" | grep -q "$VERSION" ; then
60-
DRA_BRANCH=main
61-
else
62-
if curl -s "https://storage.googleapis.com/artifacts-api/snapshots/$MAJOR_MINOR.json" | grep -q "$VERSION" ; then
63-
DRA_BRANCH="$MAJOR_MINOR"
64-
else
65-
buildkite-agent annotate "It was not possible to know the original base branch for ${BUILDKITE_BRANCH}. This won't fail - this is a feature branch." --style 'info' --context 'ctx-info-feature-branch'
66-
exit 0
67-
fi
68-
fi
69-
else
70-
buildkite-agent annotate "${BUILDKITE_BRANCH} is not supported yet. Look for the supported branches in ${BRANCHES_URL}" --style 'warning' --context 'ctx-warn'
71-
exit 1
72-
fi
44+
dra_process_other_branches
7345
fi
7446

47+
echo "--- :arrow_right: Release Manager only supports the current active branches"
48+
echo "BUILDKITE_BRANCH=$BUILDKITE_BRANCH"
49+
echo "BUILDKITE_COMMIT=$BUILDKITE_COMMIT"
50+
echo "VERSION=$VERSION"
51+
echo "Supported branches:"
52+
cat active-branches.json
53+
7554
dra() {
7655
local workflow=$1
7756
local command=$2
78-
local qualifier=${ELASTIC_QUALIFIER:-""}
57+
local qualifier=${3:-""}
7958
echo "--- Run release manager $workflow (DRA command: $command)"
8059
set -x
8160
docker run --rm \
@@ -94,32 +73,20 @@ dra() {
9473
--qualifier "$qualifier" \
9574
--version $VERSION | tee rm-output.txt
9675
set +x
97-
# Create Buildkite annotation similarly done in Beats:
98-
# https://github.com/elastic/beats/blob/90f9e8f6e48e76a83331f64f6c8c633ae6b31661/.buildkite/scripts/dra.sh#L74-L81
99-
if [[ "$command" == "collect" ]]; then
100-
# extract the summary URL from a release manager output line like:
101-
# Report summary-18.22.0.html can be found at https://artifacts-staging.elastic.co/apm-server/18.22.0-ABCDEFGH/summary-18.22.0.html
102-
SUMMARY_URL=$(grep -E '^Report summary-.* can be found at ' rm-output.txt | grep -oP 'https://\S+' | awk '{print $1}')
103-
rm rm-output.txt
10476

105-
# and make it easily clickable as a Builkite annotation
106-
printf "**${workflow} summary link:** [${SUMMARY_URL}](${SUMMARY_URL})\n" | buildkite-agent annotate --style=success --append
107-
fi
77+
create_annotation_dra_summary "$command" "$workflow" rm-output.txt
10878
}
10979

11080
if [[ "${TYPE}" == "staging" ]]; then
81+
qualifier=$(fetch_elastic_qualifier "$DRA_BRANCH")
82+
# TODO: main and 8.x are not needed to run the DRA for staging
83+
# but main is needed until we do alpha1 releases of 9.0.0
11184
if [[ "${DRA_BRANCH}" != "8.x" ]]; then
112-
echo "${DRA_BRANCH} is not '8.x'"
113-
if [[ "${DRA_BRANCH}" == "main" ]] ; then
114-
# NOTE: qualifier is needed for main/staging at the moment. Skip builds if no ELASTIC_QUALIFIER
115-
if [[ -n "${ELASTIC_QUALIFIER}" ]]; then
116-
dra "${TYPE}" "$dra_command"
117-
fi
118-
else
119-
dra "${TYPE}" "$dra_command"
120-
fi
85+
dra "${TYPE}" "$DRA_COMMAND" "${qualifier}"
12186
fi
122-
else
87+
fi
88+
89+
if [[ "${TYPE}" == "snapshot" ]]; then
12390
# NOTE: qualifier is not needed for snapshots, let's unset it.
124-
dra "snapshot" "$dra_command" ""
91+
dra "${TYPE}" "$DRA_COMMAND" ""
12592
fi

.buildkite/scripts/package.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ if [[ ${TYPE} == "snapshot" ]]; then
1919
MAKE_GOAL="${MAKE_GOAL}-snapshot"
2020
fi
2121

22+
if [[ ${TYPE} == "staging" ]]; then
23+
echo "--- Prepare the Elastic Qualifier"
24+
# NOTE: load the shared functions
25+
# shellcheck disable=SC1091
26+
source .buildkite/scripts/utils.sh
27+
dra_process_other_branches
28+
ELASTIC_QUALIFIER=$(fetch_elastic_qualifier "$DRA_BRANCH")
29+
export ELASTIC_QUALIFIER
30+
fi
31+
32+
echo "--- Run $MAKE_GOAL for $DRA_BRANCH"
2233
make $MAKE_GOAL
2334

2435
ls -l build/distributions/

.buildkite/scripts/utils.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# An opinionated approach to manage the Elatic Qualifier for the DRA in a Google Bucket
2+
# Instead of using the ELASTIC_QUALIFIER env variable.
3+
fetch_elastic_qualifier() {
4+
local branch=$1
5+
qualifier=""
6+
URL="https://storage.googleapis.com/dra-qualifier/$branch"
7+
if curl -sf -o /dev/null "$URL" ; then
8+
qualifier=$(curl -s "$URL")
9+
fi
10+
echo "$qualifier"
11+
}
12+
13+
retry() {
14+
local retries=$1
15+
shift
16+
17+
local count=0
18+
until "$@"; do
19+
exit=$?
20+
wait=$((2 ** count))
21+
count=$((count + 1))
22+
if [ $count -lt "$retries" ]; then
23+
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
24+
sleep $wait
25+
else
26+
>&2 echo "Retry $count/$retries exited $exit, no more retries left."
27+
return $exit
28+
fi
29+
done
30+
return 0
31+
}
32+
33+
#
34+
# An opinionated approach to detect if unsupported Unified Release branches
35+
# can be used, this is handy for testing feature branches in dry-run mode
36+
# It produces the below environment variables:
37+
# - VERSION
38+
# - DRA_COMMAND
39+
# - DRA_BRANCH
40+
dra_process_other_branches() {
41+
## Read current version without the qualifier
42+
VERSION=$(make get-version-only)
43+
DRA_BRANCH="$BUILDKITE_BRANCH"
44+
if [[ $BUILDKITE_BRANCH =~ "feature/" ]]; then
45+
buildkite-agent annotate "${BUILDKITE_BRANCH} will list DRA artifacts. Feature branches are not supported. Look for the supported branches in ${BRANCHES_URL}" --style 'info' --context 'ctx-info'
46+
DRA_COMMAND=list
47+
48+
# use a different branch since DRA does not support feature branches but main/release branches
49+
# for such we will use the VERSION and https://storage.googleapis.com/artifacts-api/snapshots/<major.minor>.json
50+
# to know if the branch was branched out from main or the release branches.
51+
MAJOR_MINOR=${VERSION%.*}
52+
if curl -s "https://storage.googleapis.com/artifacts-api/snapshots/main.json" | grep -q "$VERSION" ; then
53+
DRA_BRANCH=main
54+
else
55+
if curl -s "https://storage.googleapis.com/artifacts-api/snapshots/$MAJOR_MINOR.json" | grep -q "$VERSION" ; then
56+
DRA_BRANCH="$MAJOR_MINOR"
57+
else
58+
buildkite-agent annotate "It was not possible to know the original base branch for ${BUILDKITE_BRANCH}. This won't fail - this is a feature branch." --style 'info' --context 'ctx-info-feature-branch'
59+
fi
60+
fi
61+
fi
62+
export DRA_BRANCH DRA_COMMAND VERSION
63+
}
64+
65+
# Create Buildkite annotation similarly done in Beats:
66+
# https://github.com/elastic/beats/blob/90f9e8f6e48e76a83331f64f6c8c633ae6b31661/.buildkite/scripts/dra.sh#L74-L81
67+
create_annotation_dra_summary() {
68+
local command=$1
69+
local workflow=$2
70+
local output=$3
71+
if [[ "$command" == "collect" ]]; then
72+
# extract the summary URL from a release manager output line like:
73+
# Report summary-18.22.0.html can be found at https://artifacts-staging.elastic.co/apm-server/18.22.0-ABCDEFGH/summary-18.22.0.html
74+
SUMMARY_URL=$(grep -E '^Report summary-.* can be found at ' "$output" | grep -oP 'https://\S+' | awk '{print $1}')
75+
rm "$output"
76+
77+
# and make it easily clickable as a Builkite annotation
78+
printf "**${workflow} summary link:** [${SUMMARY_URL}](${SUMMARY_URL})\n" | buildkite-agent annotate --style=success --append
79+
fi
80+
}

.ci/scripts/bench.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ if [ "${CI}" == "true" ] ; then
170170
export BUILDKITE_TOKEN="${BUILDKITE_TOKEN_SECRET}"
171171

172172
echo "--- Setting up the :golang: environment..."
173-
GO_VERSION=$(cat .go-version)
173+
GO_VERSION=$(grep '^go' go.mod | cut -d' ' -f2)
174174
OS_NAME=linux
175175
OS_ARCH=amd64
176176
retry 5 curl -sL -o "${BASE_PROJECT}"/gvm "https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-${OS_NAME}-${OS_ARCH}"

.ci/scripts/unit-test.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/benchmarks.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ on:
3535
description: 'Set the expression that matches the benchmark scenarios to run'
3636
required: false
3737
type: string
38+
pgoExport:
39+
description: 'Run the benchmarks with PGO export'
40+
required: false
41+
type: boolean
42+
default: false
3843
schedule:
3944
- cron: '0 17 * * *' # Scheduled regular benchmarks.
40-
- cron: '0 5 */5 * *' # Scheduled PGO benchmarks.
45+
- cron: '0 0 1 * *' # Scheduled PGO benchmarks.
4146

4247
env:
4348
PNG_REPORT_FILE: out.png
@@ -61,10 +66,11 @@ jobs:
6166
SSH_KEY: ./id_rsa_terraform
6267
TF_VAR_private_key: ./id_rsa_terraform
6368
TF_VAR_public_key: ./id_rsa_terraform.pub
64-
TF_VAR_run_standalone: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
69+
TF_VAR_run_standalone: ${{ inputs.runStandalone || github.event.schedule=='0 0 1 * *' }}
6570
TF_VAR_apm_server_tail_sampling: ${{ inputs.enableTailSampling || 'false' }} # set the default again otherwise schedules won't work
6671
TF_VAR_apm_server_tail_sampling_storage_limit: ${{ inputs.tailSamplingStorageLimit || '10GB' }} # set the default again otherwise schedules won't work
67-
RUN_STANDALONE: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
72+
RUN_STANDALONE: ${{ inputs.runStandalone || github.event.schedule=='0 0 1 * *' }}
73+
PGO_EXPORT: ${{ inputs.pgoExport || github.event.schedule=='0 0 1 * *' }}
6874
TFVARS_SOURCE: ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile
6975
TF_VAR_BUILD_ID: ${{ github.run_id }}
7076
TF_VAR_ENVIRONMENT: ci
@@ -97,6 +103,11 @@ jobs:
97103
echo "BENCHMARK_RUN=${{ inputs.benchmarkRun }}" >> "$GITHUB_ENV"
98104
fi
99105
106+
# exclude BenchmarkTraces* from scheduled benchmarks
107+
- if: github.event_name == 'schedule'
108+
run: |
109+
echo "BENCHMARK_RUN=Benchmark[^T]" >> "$GITHUB_ENV"
110+
100111
- name: Log in to the Elastic Container registry
101112
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
102113
with:
@@ -110,7 +121,7 @@ jobs:
110121
with:
111122
role-duration-seconds: 21600 # 6 hours
112123

113-
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
124+
- uses: google-github-actions/get-secretmanager-secrets@a8440875e1c2892062aef9061228d4f1af8f919b # v2.2.3
114125
with:
115126
export_to_environment: true
116127
secrets: |-
@@ -228,13 +239,13 @@ jobs:
228239
- name: Import GPG key
229240
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
230241
with:
231-
gpg_private_key: ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
232-
passphrase: ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
242+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
243+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
233244
git_user_signingkey: true
234245
git_commit_gpgsign: true
235246

236247
- name: Open PGO PR
237-
if: ${{ env.RUN_STANDALONE == 'true' }}
248+
if: ${{ env.PGO_EXPORT == 'true' }}
238249
run: ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh
239250
env:
240251
WORKSPACE_PATH: ${{ github.workspace }}
@@ -246,7 +257,7 @@ jobs:
246257
# there is a high chance things will stop working
247258
# This is trying to reduce the chances of that happening.
248259
# See https://github.com/elastic/observability-test-environments/actions/workflows/cluster-rotate-api-keys.yml
249-
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
260+
- uses: google-github-actions/get-secretmanager-secrets@a8440875e1c2892062aef9061228d4f1af8f919b # v2.2.3
250261
if: always()
251262
with:
252263
export_to_environment: true

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- 7.1*
88
- 8.*
9+
- 9.*
910
paths-ignore: # When updating the list of expressions also update ci-docs.yml
1011
- '**.md'
1112
- '**.asciidoc'
@@ -36,9 +37,6 @@ jobs:
3637
go.sum
3738
tools/go.sum
3839
- run: make check-full
39-
- name: Ensure .go-version is up to date
40-
run: make update-go-version
41-
if: ${{ github.ref == 'main' }}
4240

4341
test:
4442
strategy:

.github/workflows/functional-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
- uses: elastic/oblt-actions/google/auth@v1
4141

42-
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
42+
- uses: google-github-actions/get-secretmanager-secrets@a8440875e1c2892062aef9061228d4f1af8f919b # v2.2.3
4343
with:
4444
export_to_environment: true
4545
secrets: |-

.github/workflows/microbenchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
push:
88
branches:
99
- main
10-
- "8.[0-9]+"
11-
- "8.x"
10+
- "8.*"
11+
- "9.*"
1212
paths-ignore:
1313
- '**.md'
1414
- '**.asciidoc'

0 commit comments

Comments
 (0)