Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[smp]: prevent some empty regression detector comments #30777

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

goxberry
Copy link
Contributor

@goxberry goxberry commented Nov 5, 2024

What does this PR do?

If the Regression Detector fails to submit a job to SMP, an empty Regression Detector PR comment is posted to PRs. This empty comment is noise and undesirable, so this pull request tests whether the Regression Detector generated a Markdown report before attempting to post. If the Markdown report does not exist, the Regression Detector PR comment will echo an error message and emit a non-zero exit code so that the PR comment job fails before posting.

Motivation

Reduce PR comment noise.

Describe how to test/QA your changes

Running this PR in CI should test its changes.

Possible Drawbacks / Trade-offs

Minor increase in CI config complexity to reduce incidence of empty Regression Detector posts that do nothing but add to alert noise.

Additional Notes

n/a

@goxberry goxberry added changelog/no-changelog team/single-machine-performance Single Machine Performance qa/no-code-change No code change in Agent code requiring validation labels Nov 5, 2024
@goxberry goxberry requested a review from a team as a code owner November 5, 2024 16:28
@github-actions github-actions bot added the short review PR is simple enough to be reviewed quickly label Nov 5, 2024
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Nov 5, 2024

Gitlab CI Configuration Changes

Modified Jobs

single-machine-performance-regression_detector
  single-machine-performance-regression_detector:
    allow_failure: true
    artifacts:
      expire_in: 1 weeks
      paths:
      - submission_metadata
      - ${CI_COMMIT_SHA}-baseline_sha
      - outputs/report.md
      - outputs/regression_signal.json
      - outputs/bounds_check_signal.json
      - outputs/junit.xml
      when: always
    image: registry.ddbuild.io/ci/datadog-agent-buildimages/docker_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs:
    - artifacts: false
      job: single_machine_performance-amd64-a7
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: never
    - if: $CI_COMMIT_BRANCH =~ /^[0-9]+\.[0-9]+\.x$/
      when: never
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - when: on_success
    script:
    - mkdir outputs
-   - touch outputs/report.md
    - git fetch origin
    - SMP_BASE_BRANCH=$(inv release.get-release-json-value base_branch)
    - echo "Looking for merge base for branch ${SMP_BASE_BRANCH}"
    - SMP_MERGE_BASE=$(git merge-base ${CI_COMMIT_SHA} origin/${SMP_BASE_BRANCH})
    - echo "Merge base is ${SMP_MERGE_BASE}"
    - AWS_NAMED_PROFILE="single-machine-performance"
    - SMP_ACCOUNT_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SMP_ACCOUNT_ID) ||
      exit $?
    - SMP_ECR_URL=${SMP_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com
    - SMP_AGENT_TEAM_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SMP_AGENT_TEAM_ID)
      || exit $?
    - SMP_API=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SMP_API) || exit $?
    - SMP_BOT_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SMP_BOT_ACCESS_KEY_ID)
      || exit $?
    - SMP_BOT_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SMP_BOT_ACCESS_KEY) ||
      exit $?
    - aws configure set aws_access_key_id "$SMP_BOT_ID" --profile ${AWS_NAMED_PROFILE}
    - aws configure set aws_secret_access_key "$SMP_BOT_KEY" --profile ${AWS_NAMED_PROFILE}
    - aws configure set region us-west-2 --profile ${AWS_NAMED_PROFILE}
    - aws --profile single-machine-performance s3 cp s3://smp-cli-releases/v${SMP_VERSION}/x86_64-unknown-linux-gnu/smp
      smp
    - chmod +x smp
    - BASELINE_SHA="${SMP_MERGE_BASE}"
    - echo "Computing baseline..."
    - echo "Checking if commit ${BASELINE_SHA} is recent enough..."
    - FOUR_DAYS_BEFORE_NOW=$(date --date="-4 days +1 hour" "+%s")
    - BASELINE_COMMIT_TIME=$(git -c log.showSignature=false show --no-patch --format=%ct
      ${BASELINE_SHA})
    - "if [[ ${BASELINE_COMMIT_TIME} -le ${FOUR_DAYS_BEFORE_NOW} ]]\nthen\n    echo\
      \ \"ERROR: Merge-base of this branch is too old for SMP. Please update your branch\
      \ by merging an up-to-date main branch into your branch or by rebasing it on an\
      \ up-to-date main branch.\"\n    exit 1\nfi\n"
    - echo "Commit ${BASELINE_SHA} is recent enough"
    - echo "Checking if image exists for commit ${BASELINE_SHA}..."
    - "while [[ ! $(aws ecr describe-images --region us-west-2 --profile single-machine-performance\
      \ --registry-id \"${SMP_ACCOUNT_ID}\" --repository-name \"${SMP_AGENT_TEAM_ID}-agent\"\
      \ --image-ids imageTag=\"${BASELINE_SHA}-7-amd64\") ]]\ndo\n    echo \"No image\
      \ exists for ${BASELINE_SHA} - checking predecessor of ${BASELINE_SHA} next\"\n\
      \    BASELINE_SHA=$(git rev-parse ${BASELINE_SHA}^)\n    echo \"Checking if commit\
      \ ${BASELINE_SHA} is recent enough...\"\n    BASELINE_COMMIT_TIME=$(git -c log.showSignature=false\
      \ show --no-patch --format=%ct ${BASELINE_SHA})\n    if [[ ${BASELINE_COMMIT_TIME}\
      \ -le ${FOUR_DAYS_BEFORE_NOW} ]]\n    then\n        echo \"ERROR: Merge-base of\
      \ this branch is too old for SMP. Please update your branch by merging an up-to-date\
      \ main branch into your branch or by rebasing it on an up-to-date main branch.\"\
      \n        exit 1\n    fi\n    echo \"Commit ${BASELINE_SHA} is recent enough\"\
      \n    echo \"Checking if image exists for commit ${BASELINE_SHA}...\"\ndone\n"
    - echo "Image exists for commit ${BASELINE_SHA}"
    - echo "Baseline SHA is ${BASELINE_SHA}"
    - echo -n "${BASELINE_SHA}" > "${CI_COMMIT_SHA}-baseline_sha"
    - 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
    - echo "${CI_COMMIT_SHA} | ${COMPARISON_IMAGE}"
    - RUST_LOG="info,aws_config::profile::credentials=error"
    - RUST_LOG_DEBUG="debug,aws_config::profile::credentials=error"
    - RUST_LOG="${RUST_LOG}" ./smp --team-id ${SMP_AGENT_TEAM_ID} --api-base ${SMP_API}
      --aws-named-profile ${AWS_NAMED_PROFILE} job submit --baseline-image ${BASELINE_IMAGE}
      --comparison-image ${COMPARISON_IMAGE} --baseline-sha ${BASELINE_SHA} --comparison-sha
      ${CI_COMMIT_SHA} --target-config-dir test/regression/ --submission-metadata submission_metadata
    - RUST_LOG="${RUST_LOG}" ./smp --team-id ${SMP_AGENT_TEAM_ID} --api-base ${SMP_API}
      --aws-named-profile ${AWS_NAMED_PROFILE} job status --wait --wait-delay-seconds
      60 --submission-metadata submission_metadata
    - RUST_LOG="${RUST_LOG}" ./smp --team-id ${SMP_AGENT_TEAM_ID} --api-base ${SMP_API}
      --aws-named-profile ${AWS_NAMED_PROFILE} job sync --submission-metadata submission_metadata
      --output-path outputs
    - cat outputs/report.md | sed "s/^\$/$(echo -ne '\uFEFF\u00A0\u200B')/g"
    - DATADOG_API_KEY="$("$CI_PROJECT_DIR"/tools/ci/fetch_secret.sh "$AGENT_API_KEY_ORG2"
      token)" || exit $?; export DATADOG_API_KEY
    - datadog-ci junit upload --service datadog-agent outputs/junit.xml
    - RUST_LOG="${RUST_LOG}" ./smp --team-id ${SMP_AGENT_TEAM_ID} --api-base ${SMP_API}
      --aws-named-profile ${AWS_NAMED_PROFILE} job result --submission-metadata submission_metadata
    stage: functional_test
    tags:
    - arch:amd64
    timeout: 1h10m
    variables:
      SMP_VERSION: 0.18.1
single-machine-performance-regression_detector-pr-comment
  single-machine-performance-regression_detector-pr-comment:
    allow_failure: true
    artifacts:
      expire_in: 1 weeks
      paths:
      - report_as_json_string.txt
      - pr_comment_payload.json
    image:
      entrypoint:
      - ''
      name: 486234852809.dkr.ecr.us-east-1.amazonaws.com/pr-commenter:3
    needs:
    - job: single-machine-performance-regression_detector
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: never
    - if: $CI_COMMIT_BRANCH =~ /^[0-9]+\.[0-9]+\.x$/
      when: never
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - when: on_success
    script:
+   - "if [[ ! -s \"outputs/report.md\" ]]\nthen\n    echo \"ERROR: Regression Detector\
+     \ report not found -- no PR comment posted\"\n    exit 1\nfi\n"
    - cat outputs/report.md | sed -z 's/\n/\\n/g' | sed -z 's/"/\\"/g' > report_as_json_string.txt
    - cat report_as_json_string.txt
    - PR_COMMENT_JSON_PAYLOAD='{"org":"DataDog", "repo":"datadog-agent", "commit":"'"${CI_COMMIT_SHA}"'",
      "header":"Regression Detector", "message":"'"$(cat report_as_json_string.txt)"'"}'
    - printf "%s\n" "PR comment JSON payload:${PR_COMMENT_JSON_PAYLOAD}"
    - printf "%s\n" "${PR_COMMENT_JSON_PAYLOAD}" > pr_comment_payload.json
    - "set +e\nout=$(curl https://pr-commenter.us1.ddbuild.io/internal/cit/pr-comment\
      \ \\\n    -H \"$(authanywhere)\" \\\n    -H \"X-DdOrigin: curl\" \\\n    -X PATCH\
      \ \\\n    -d \"${PR_COMMENT_JSON_PAYLOAD}\")\nexitcode=$?\nset -e\nif [ -n \"\
      ${out}\" ]; then\n  if [ $exitcode -eq 0 ]; then\n    echo $out\n  else\n    echo\
      \ $out >&2\n  fi\nfi\nif [ \"${out}\" != \"${out/invalid request: no pr found\
      \ for this commit}\" ]; then\n  exit 0\nfi\nexit $exitcode\n"
    stage: functional_test
    tags:
    - arch:amd64
    variables:
      FF_KUBERNETES_HONOR_ENTRYPOINT: false

Changes Summary

Removed Modified Added Renamed
0 2 0 0

ℹ️ Diff available in the job log.

@goxberry
Copy link
Contributor Author

goxberry commented Nov 5, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 5, 2024

🚂 MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Nov 5, 2024

[Fast Unit Tests Report]

On pipeline 48389414 (CI Visibility). The following jobs did not run any unit tests:

Jobs:
  • tests_deb-arm64-py3
  • tests_deb-x64-py3
  • tests_flavor_dogstatsd_deb-x64
  • tests_flavor_heroku_deb-x64
  • tests_flavor_iot_deb-x64
  • tests_rpm-arm64-py3
  • tests_rpm-x64-py3
  • tests_windows-x64

If you modified Go files and expected unit tests to run in these jobs, please double check the job logs. If you think tests should have been executed reach out to #agent-devx-help

@dd-devflow
Copy link

dd-devflow bot commented Nov 5, 2024

⚠️ MergeQueue: This merge request was unqueued

This merge request was unqueued

If you need support, contact us on Slack #devflow!

@goxberry
Copy link
Contributor Author

goxberry commented Nov 6, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 6, 2024

🚂 MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Nov 6, 2024

⚠️ MergeQueue: This merge request was unqueued

This merge request was unqueued

If you need support, contact us on Slack #devflow!

If the Regression Detector fails to submit a job to SMP, an empty
Regression Detector PR comment is posted to PRs. This empty comment is
noise and undesirable, so this commit tests whether the Regression
Detector generated a Markdown report before attempting to post. If the
Markdown report does not exist, the Regression Detector PR comment
will echo an error message and emit a non-zero exit code so that the
PR comment job fails before posting.

Signed-off-by: Geoffrey M. Oxberry <geoffrey.oxberry@datadoghq.com>
@goxberry goxberry force-pushed the goxberry/stop-posting-empty-smp-pr-comments branch from 6171322 to 726d372 Compare November 6, 2024 20:09
Copy link

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: a50a9c03-103c-4d5e-a20e-7aebfa7cd663

Baseline: 47294c1
Comparison: 726d372
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
file_tree memory utilization +3.10 [+2.95, +3.25] 1 Logs
basic_py_check % cpu utilization +2.87 [-1.12, +6.86] 1 Logs
quality_gate_idle_all_features memory utilization +2.24 [+2.10, +2.38] 1 Logs bounds checks dashboard
pycheck_lots_of_tags % cpu utilization +1.48 [-2.07, +5.03] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.45 [-0.28, +1.18] 1 Logs
tcp_syslog_to_blackhole ingress throughput +0.44 [+0.37, +0.50] 1 Logs
idle memory utilization +0.28 [+0.23, +0.34] 1 Logs bounds checks dashboard
file_to_blackhole_1000ms_latency egress throughput +0.08 [-0.41, +0.57] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.01] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.00 [-0.34, +0.34] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.09, +0.09] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.00 [-0.23, +0.22] 1 Logs
quality_gate_idle memory utilization -0.01 [-0.06, +0.04] 1 Logs bounds checks dashboard
idle_all_features memory utilization -0.02 [-0.12, +0.09] 1 Logs bounds checks dashboard
file_to_blackhole_300ms_latency egress throughput -0.07 [-0.25, +0.11] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.13 [-0.38, +0.12] 1 Logs

Bounds Checks: ❌ Failed

perf experiment bounds_check_name replicates_passed links
idle memory_usage 8/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 8/10 bounds checks dashboard
quality_gate_idle memory_usage 9/10 bounds checks dashboard
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
idle_all_features memory_usage 10/10 bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@goxberry
Copy link
Contributor Author

goxberry commented Nov 6, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Nov 6, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 23m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit 6fd7141 into main Nov 6, 2024
214 checks passed
@dd-mergequeue dd-mergequeue bot deleted the goxberry/stop-posting-empty-smp-pr-comments branch November 6, 2024 22:01
@github-actions github-actions bot added this to the 7.61.0 milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog qa/no-code-change No code change in Agent code requiring validation short review PR is simple enough to be reviewed quickly team/single-machine-performance Single Machine Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants