diff --git a/.gitlab/container_build/docker_linux.yml b/.gitlab/container_build/docker_linux.yml index 9dfd539b4676a..19289b03e5261 100644 --- a/.gitlab/container_build/docker_linux.yml +++ b/.gitlab/container_build/docker_linux.yml @@ -119,23 +119,6 @@ docker_build_agent7: TAG_SUFFIX: -7 BUILD_ARG: --target test --build-arg PYTHON_VERSION=3 --build-arg DD_AGENT_ARTIFACT=datadog-agent_7*_amd64.deb -single_machine_performance-push-main-sha: - stage: container_build - rules: - - !reference [.on_main_a7] - image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/docker_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES - tags: ["runner:docker"] - needs: - - docker_build_agent7 - script: - - echo -n ${CI_COMMIT_SHA} > .main_sha - - SMP_ACCOUNT_ID=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.single-machine-performance-account-id --with-decryption --query "Parameter.Value" --out text) - - SMP_AGENT_TEAM_ID=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.single-machine-performance-agent-team-id --with-decryption --query "Parameter.Value" --out text) - - aws configure set aws_access_key_id $(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.single-machine-performance-bot-access-key-id --with-decryption --query "Parameter.Value" --out text) --profile single-machine-performance - - aws configure set aws_secret_access_key $(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.single-machine-performance-bot-access-key --with-decryption --query "Parameter.Value" --out text) --profile single-machine-performance - - aws configure set region us-west-2 --profile single-machine-performance - - aws s3 cp --profile single-machine-performance --only-show-errors .main_sha s3://${SMP_AGENT_TEAM_ID}-smp-artifacts/information/latest_main_sha - single_machine_performance-amd64-a7: extends: .docker_publish_job_definition stage: container_build diff --git a/.gitlab/functional_test/regression_detector.yml b/.gitlab/functional_test/regression_detector.yml index 041f06ad69615..0d362fa22ef32 100644 --- a/.gitlab/functional_test/regression_detector.yml +++ b/.gitlab/functional_test/regression_detector.yml @@ -8,7 +8,10 @@ single-machine-performance-regression_detector: artifacts: expire_in: 1 weeks paths: - - submission_metadata + - submission_metadata # for provenance, debugging + - ${CI_COMMIT_SHA}-baseline_sha # for provenance, debugging + - outputs/report.md # for debugging, also on S3 + - outputs/report.html # for debugging, also on S3 when: always variables: SMP_VERSION: 0.7.3 @@ -22,7 +25,7 @@ single-machine-performance-regression_detector: # 'comparison'. We are guaranteed by the structure of the pipeline that # 'comparison' exists, not so much with 'baseline' as it has to come from main # merge pipeline run. This is solved in datadog-agent by updating a file in S3 - # with the SHA of the latest passing build from main. It's solved in Vector by + # with the SHA of the merge base from main. It's solved in Vector by # building Vector twice for each Regression Detector run. # # We allow failure for now. _Unfortunately_ this also means that if the @@ -30,6 +33,14 @@ single-machine-performance-regression_detector: # flagged. allow_failure: true script: + # Ensure output files exist for artifact downloads step + - mkdir outputs # Also needed for smp job sync step + - touch outputs/report.md # Will be emitted by smp job sync + - touch outputs/report.html # Will be emitted by smp job sync + # Compute merge base of current commit and `main` + - git fetch origin + - SMP_MERGE_BASE=$(git merge-base ${CI_COMMIT_SHA} origin/main) + - echo "Merge base is ${SMP_MERGE_BASE}" # Setup AWS credentials for single-machine-performance AWS account - AWS_NAMED_PROFILE="single-machine-performance" - SMP_ACCOUNT_ID=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.single-machine-performance-account-id --with-decryption --query "Parameter.Value" --out text) @@ -41,11 +52,15 @@ single-machine-performance-regression_detector: # Download smp binary and prepare it for use - aws --profile single-machine-performance s3 cp s3://smp-cli-releases/v${SMP_VERSION}/x86_64-unknown-linux-musl/smp smp - chmod +x smp - # Submit job, using the SHA of the last successful main commit as baseline. - # This will have been built in a separate pipeline run. The comparison will - # have been built previously in this pipeline run. - - aws --profile ${AWS_NAMED_PROFILE} s3 cp --only-show-errors s3://${SMP_AGENT_TEAM_ID}-smp-artifacts/information/latest_main_sha .latest_main_sha - - BASELINE_SHA=$(cat .latest_main_sha) + - BASELINE_SHA="${SMP_MERGE_BASE}" + - echo "Computing baseline..." + - echo "Checking if image exists for commit ${BASELINE_SHA}..." + - while [[ ! $(aws ecr describe-images --profile single-machine-performance --registry-id "${SMP_ACCOUNT_ID}" --repository-name "${SMP_AGENT_TEAM_ID}-agent" --image-ids imageTag="${BASELINE_SHA}-7-amd64") ]]; do echo "No image exists for ${BASELINE_SHA} - checking predecessor of ${BASELINE_SHA} next"; BASELINE_SHA=$(git rev-parse ${BASELINE_SHA}^); echo "Checking if image exists for commit ${BASELINE_SHA}..."; done + - echo "Image exists for commit ${BASELINE_SHA}" + - echo "Baseline SHA is ${BASELINE_SHA}" + - echo -n "${BASELINE_SHA}" > "${CI_COMMIT_SHA}-baseline_sha" + # Copy the baseline SHA to SMP for debugging purposes later + - aws s3 cp --profile single-machine-performance --only-show-errors "${CI_COMMIT_SHA}-baseline_sha" "s3://${SMP_AGENT_TEAM_ID}-smp-artifacts/information/" - BASELINE_IMAGE=${SMP_ECR_URL}/${SMP_AGENT_TEAM_ID}-agent:${BASELINE_SHA}-7-amd64 - echo "${BASELINE_SHA} | ${BASELINE_IMAGE}" - COMPARISON_IMAGE=${SMP_ECR_URL}/${SMP_AGENT_TEAM_ID}-agent:${CI_COMMIT_SHA}-7-amd64 @@ -76,7 +91,6 @@ single-machine-performance-regression_detector: --wait-delay-seconds 60 --submission-metadata submission_metadata # Now that the job is completed pull the analysis report, output it to stdout. - - mkdir outputs - RUST_LOG="${RUST_LOG}" ./smp --team-id ${SMP_AGENT_TEAM_ID} --aws-named-profile ${AWS_NAMED_PROFILE} job sync --submission-metadata submission_metadata @@ -93,7 +107,7 @@ single-machine-performance-regression_detector: - dpkg -i dd-package.deb - rm dd-package.deb - apt-get update - - dd-package --bucket binaries.ddbuild.io --package devtools/dd-package-dev + - dd-package --bucket binaries.ddbuild.io --package devtools/dd-package-dev --distribution "20.04" # Kludge from https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4645#note_287636439 to avoid # doubled output - echo "" @@ -103,7 +117,8 @@ single-machine-performance-regression_detector: - "# beneath the error message in the GitLab CI logs #" - "#################################################################################" - echo "" - - dd-package --bucket binaries.ddbuild.io --package devtools/pr-commenter + # Pinned version of pr-commenter taken from https://github.com/DataDog/dogweb/blob/b2a891c2a2186b8fecd27ca9b13ebabe5f289a4a/tasks/gitlab/k8s-diff-helper.sh#L22 + - dd-package --bucket binaries.ddbuild.io --package devtools/pr-commenter --distribution "20.04" --version "14692290-a6440fd1" # Post HTML report to GitHub - cat outputs/report.html | /usr/local/bin/pr-commenter --for-pr="$CI_COMMIT_REF_NAME" # Finally, exit 1 if the job signals a regression else 0.