Skip to content

Commit

Permalink
Merge branch 'main' into dev-docs/release-clarify-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
1pkg authored Dec 3, 2024
2 parents 43eb411 + 9aa5958 commit dacb6d9
Show file tree
Hide file tree
Showing 168 changed files with 5,241 additions and 4,813 deletions.
6 changes: 6 additions & 0 deletions .buildkite/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ steps:
artifact_paths:
- "build/distributions/**/*"
- "build/dependencies*.csv"
retry:
automatic:
- limit: 1

- label: "Package Ubuntu-20 aarch64"
key: "package-arm"
Expand All @@ -43,6 +46,9 @@ steps:
- "staging"
artifact_paths:
- "build/distributions/**/*"
retry:
automatic:
- limit: 1

- label: "DRA"
key: "dra"
Expand Down
9 changes: 7 additions & 2 deletions .buildkite/scripts/dra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ DRA_BRANCH="$BUILDKITE_BRANCH"
dra_command=collect
BRANCHES_URL=https://storage.googleapis.com/artifacts-api/snapshots/branches.json
curl -s "${BRANCHES_URL}" > active-branches.json
if ! grep -q "\"$BUILDKITE_BRANCH\"" active-branches.json ; then
# as long as `8.x` is not in the active branches, we will explicitly add the condition.
if [ "$BUILDKITE_BRANCH" == "8.x" ] || grep -q "\"$BUILDKITE_BRANCH\"" active-branches.json ; then
echo "--- :arrow_right: Release Manager only supports the current active branches and 8.x, running"
else
# If no active branches are found, let's see if it is a feature branch.
echo "--- :arrow_right: Release Manager only supports the current active branches, skipping"
echo "BUILDKITE_BRANCH=$BUILDKITE_BRANCH"
echo "BUILDKITE_COMMIT=$BUILDKITE_COMMIT"
Expand Down Expand Up @@ -98,6 +102,7 @@ dra() {
}

dra "snapshot" "$dra_command"
if [[ "${DRA_BRANCH}" != "main" ]]; then
if [[ "${DRA_BRANCH}" != "main" && "${DRA_BRANCH}" != "8.x" ]]; then
echo "DRA_BRANCH is neither 'main' nor '8.x'"
dra "staging" "$dra_command"
fi
15 changes: 15 additions & 0 deletions .ci/scripts/push-pgo-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -eo pipefail

PGO_BRANCH="update-pgo-$(date +%s)"
cd $WORKSPACE_PATH
git fetch origin main
git checkout main
git checkout -b $PGO_BRANCH
mv $PROFILE_PATH x-pack/apm-server/default.pgo
git add x-pack/apm-server/default.pgo
git commit -m "PGO: Update default.pgo from benchmarks $WORKFLOW."
git push -u origin $PGO_BRANCH
gh pr create -B main -H $PGO_BRANCH -t "PGO: Update default.pgo" -b "Update default.pgo CPU profile from the benchmarks [workflow]($WORKFLOW)." -R elastic/apm-server
gh pr merge --auto --delete-branch --squash $PGO_BRANCH
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ scms:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: elastic
repository: apm-server
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "BRANCH" }}'
commitusingapi: true
Expand Down
5 changes: 3 additions & 2 deletions .ci/bump-golang.yml → .ci/updatecli/bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ scms:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: elastic
repository: apm-server
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "GITHUB_BRANCH" }}'
commitusingapi: true
Expand Down
5 changes: 3 additions & 2 deletions .ci/update-beats.yml → .ci/updatecli/update-beats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ scms:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: elastic
repository: apm-server
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "BRANCH_NAME" }}'
commitusingapi: true
Expand Down
2 changes: 2 additions & 0 deletions .ci/updatecli/values.d/ironbank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config:
- path: packaging/ironbank
9 changes: 9 additions & 0 deletions .ci/updatecli/values.d/scm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
scm:
enabled: true
owner: elastic
repository: apm-server
branch: main
commitusingapi: true
# begin updatecli-compose policy values
user: obltmachine
# end updatecli-compose policy values
3 changes: 3 additions & 0 deletions .ci/updatecli/values.d/updatecli-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spec:
files:
- "updatecli-compose.yaml"
13 changes: 12 additions & 1 deletion .github/workflows/add-to-docs-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ jobs:
runs-on: ubuntu-latest
if: github.event.label.name == 'Team:Docs'
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"organization_projects": "write",
"issues": "read"
}
- uses: octokit/[email protected]
id: add_to_project
with:
Expand All @@ -28,4 +39,4 @@ jobs:
contentid: ${{ github.event.issue.node_id }}
env:
PROJECT_ID: "PVT_kwDOAGc3Zs0iZw"
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
13 changes: 12 additions & 1 deletion .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ jobs:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"organization_projects": "write",
"issues": "read"
}
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/elastic/projects/1286
github-token: ${{ secrets.APM_TECH_USER_TOKEN }}
github-token: ${{ steps.get_token.outputs.token }}
117 changes: 102 additions & 15 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: benchmarks
on:
workflow_dispatch:
inputs:
runStandalone:
description: 'Run the benchmarks against standalone APM Server with Moxy'
required: false
type: boolean
default: false
profile:
description: 'The system profile used to run the benchmarks'
required: false
Expand All @@ -21,10 +26,12 @@ on:
required: false
type: string
schedule:
- cron: '0 17 * * *'
- cron: '0 17 * * *' # Scheduled regular benchmarks.
- cron: '0 5 */5 * *' # Scheduled PGO benchmarks.

env:
PNG_REPORT_FILE: out.png
BENCHMARK_CPU_OUT: default.pgo
BENCHMARK_RESULT: benchmark-result.txt
WORKING_DIRECTORY: testing/benchmark

Expand All @@ -38,12 +45,14 @@ jobs:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
permissions:
contents: read
contents: write
id-token: write
env:
SSH_KEY: ./id_rsa_terraform
TF_VAR_private_key: ./id_rsa_terraform
TF_VAR_public_key: ./id_rsa_terraform.pub
TF_VAR_run_standalone: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
RUN_STANDALONE: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
TFVARS_SOURCE: ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile
TF_VAR_BUILD_ID: ${{ github.run_id }}
TF_VAR_ENVIRONMENT: ci
Expand All @@ -59,7 +68,7 @@ jobs:
with:
go-version-file: 'go.mod'

- uses: rlespinasse/github-slug-action@797d68864753cbceedc271349d402da4590e6302
- uses: rlespinasse/github-slug-action@aba9f8db6ef36e0733227a62673d6592b1f430ea

- name: Set up env
run: |
Expand Down Expand Up @@ -90,7 +99,7 @@ jobs:
with:
role-duration-seconds: 18000 # 5 hours

- uses: google-github-actions/get-secretmanager-secrets@95a0b09b8348ef3d02c68c6ba5662a037e78d713 # v2.1.4
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
with:
export_to_environment: true
secrets: |-
Expand All @@ -101,28 +110,44 @@ jobs:
terraform_version: 1.3.7
terraform_wrapper: false

- name: Init terraform module
id: init
run: make init

- name: Build apmbench
run: make apmbench $SSH_KEY terraform.tfvars

- name: Build APM Server and Moxy
if: ${{ env.RUN_STANDALONE == 'true' }}
run: |
make apm-server
make moxy
- name: Override docker committed version
if: ${{ ! inputs.runOnStable }}
if: ${{ ! inputs.runOnStable && env.RUN_STANDALONE == 'false' }}
run: make docker-override-committed-version

- name: Spin up benchmark environment
id: deploy
run: |
make init apply
make apply
admin_console_url=$(terraform output -raw admin_console_url)
echo "admin_console_url=$admin_console_url" >> "$GITHUB_OUTPUT"
echo "-> infra setup done"
- name: Run benchmarks autotuned
if: ${{ inputs.benchmarkAgents == '' }}
run: make run-benchmark-autotuned index-benchmark-results
run: make run-benchmark-autotuned

- name: Run benchmarks self tuned
if: ${{ inputs.benchmarkAgents != '' }}
run: make run-benchmark index-benchmark-results
run: make run-benchmark

- name: Cat standalone server logs
if: ${{ env.RUN_STANDALONE == 'true' && failure() }}
run: make cat-apm-server-logs

- name: Index benchmarks result
run: make index-benchmark-results

- name: Download PNG
run: >-
Expand Down Expand Up @@ -150,15 +175,76 @@ jobs:
- name: Upload benchmark result
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-result
path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }}
if-no-files-found: error

# The next section injects CPU profile collected by apmbench into the build.
# By copying the profile, uploading it to the artifacts and pushing it
# via a PR to update default.pgo.

- name: Copy CPU profile
run: make cp-cpuprof

- name: Upload CPU profile
uses: actions/upload-artifact@v4
with:
name: cpu-profile
path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
if-no-files-found: error

- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
# Required to use a service account, otherwise PRs created by
# GitHub bot won't trigger any CI builds.
# See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081
- name: Configure git user
uses: elastic/oblt-actions/git/setup@v1
with:
github-token: ${{ steps.get_token.outputs.token }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
with:
gpg_private_key: ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Open PGO PR
if: ${{ env.RUN_STANDALONE == 'true' }}
run: ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh
env:
WORKSPACE_PATH: ${{ github.workspace }}
PROFILE_PATH: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
WORKFLOW: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}

# Secrets are rotated daily, if the benchmarks run between the rotation window, then
# there is a high chance things will stop working
# This is trying to reduce the chances of that happening.
# See https://github.com/elastic/observability-test-environments/actions/workflows/cluster-rotate-api-keys.yml
- uses: google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
if: always()
with:
export_to_environment: true
secrets: |-
EC_API_KEY:elastic-observability/elastic-cloud-observability-team-pro-api-key
- name: Tear down benchmark environment
if: always()
run: make destroy
run: make init destroy

# Notify failure to Slack only on schedule (nightly run)
- if: failure() && github.event_name == 'schedule'
Expand All @@ -170,13 +256,14 @@ jobs:

# Notify result to Slack only on schedule (nightly run)
- if: github.event_name == 'schedule'
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
channel-id: "#apm-server"
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#apm-server",
"text": "${{ github.event_name == 'schedule' && 'Nightly' || '' }} APM Server benchmarks succesfully executed!",
"blocks": [
{
"type": "section",
Expand Down
Loading

0 comments on commit dacb6d9

Please sign in to comment.