datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[gitlab] fixing failed before_script variable expansion

Open truthbk opened this issue 1 year ago • 3 comments

What does this PR do?

Unfortunately variable expansion in gitlab will not work if the before_script is in the same job, hence why we need to resort to an additional hidden job.

This was called out, and rightfully so, in the review to #29215. Unfortunately the refactor suggested actually broke the beta releases for the reason mentioned above. This was later fixed in branch 7.57.x-otel-beta-v1 and this is a backport of that fix.

Motivation

Fix version resolving for OTel beta images.

Additional Notes

Possible Drawbacks / Trade-offs

Gitlab jobs are hard to follow due to this kind of unexpected behavior with the YAML templating, merging and its run-time resolution, etc.

Describe how to test/QA your changes

This has been tested in 7.57.x-otel-beta-v1, producing the right versions with the correct version tags. If you're so inclined, running the manual jobs and publishing an otel image with this code should succeed.

truthbk avatar Sep 13 '24 12:09 truthbk

[Fast Unit Tests Report]

On pipeline 44453525 (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

Gitlab CI Configuration Changes

Modified Jobs

deploy_containers-ot
  deploy_containers-ot:
    before_script:
+   - source /root/.bashrc
    - if [[ "$VERSION" == "" ]]; then export VERSION="$(inv agent.version --major-version
      7 --url-safe --pipeline-id $PARENT_PIPELINE_ID)"; fi
    - export IMG_SOURCES="${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-ot-beta${JMX}-amd64,${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-ot-beta${JMX}-arm64"
    - export IMG_DESTINATIONS="${AGENT_REPOSITORY}:${VERSION}-ot-beta${JMX}"
    dependencies: []
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    parallel:
      matrix:
      - JMX:
        - ''
        - -jmx
    rules:
    - allow_failure: true
      when: manual
    script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - "if [[ \"$BUCKET_BRANCH\" == \"nightly\" && ( \"$IMG_SOURCES\" =~ \"$SRC_AGENT\"\
      \ || \"$IMG_SOURCES\" =~ \"$SRC_DCA\" || \"$IMG_SOURCES\" =~ \"$SRC_CWS_INSTRUMENTATION\"\
      \ || \"$IMG_VARIABLES\" =~ \"$SRC_AGENT\" || \"$IMG_VARIABLES\" =~ \"$SRC_DCA\"\
      \ || \"$IMG_VARIABLES\" =~ \"$SRC_CWS_INSTRUMENTATION\" ) ]]; then\n  export ECR_RELEASE_SUFFIX=\"\
      -nightly\"\nelse\n  export ECR_RELEASE_SUFFIX=\"${CI_COMMIT_TAG+-release}\"\n\
      fi\n"
    - IMG_VARIABLES="$(sed -E "s#(${SRC_AGENT}|${SRC_DSD}|${SRC_DCA}|${SRC_CWS_INSTRUMENTATION})#\1${ECR_RELEASE_SUFFIX}#g"
      <<<"$IMG_VARIABLES")"
    - IMG_SOURCES="$(sed -E "s#(${SRC_AGENT}|${SRC_DSD}|${SRC_DCA}|${SRC_CWS_INSTRUMENTATION})#\1${ECR_RELEASE_SUFFIX}#g"
      <<<"$IMG_SOURCES")"
    - inv pipeline.trigger-child-pipeline --project-name DataDog/public-images --git-ref
      main --timeout 1800 --variable IMG_VARIABLES --variable IMG_REGISTRIES --variable
      IMG_SOURCES --variable IMG_DESTINATIONS --variable IMG_SIGNING --variable APPS
      --variable BAZEL_TARGET --variable DDR --variable DDR_WORKFLOW_ID --variable TARGET_ENV
      --variable DYNAMIC_BUILD_RENDER_TARGET_FORWARD_PARAMETERS
    stage: deploy_containers
    tags:
    - arch:amd64
    variables:
      AGENT_REPOSITORY: agent
      IMG_REGISTRIES: public
      IMG_SIGNING: ''
      IMG_VARIABLES: ''
      SRC_AGENT: registry.ddbuild.io/ci/datadog-agent/agent
      SRC_CWS_INSTRUMENTATION: registry.ddbuild.io/ci/datadog-agent/cws-instrumentation
      SRC_DCA: registry.ddbuild.io/ci/datadog-agent/cluster-agent
      SRC_DSD: registry.ddbuild.io/ci/datadog-agent/dogstatsd

Changes Summary

Removed Modified Added Renamed
0 1 0 0

pr-commenter[bot] avatar Sep 14 '24 00:09 pr-commenter[bot]

Regression Detector

Regression Detector Results

Run ID: 740cece8-0bbf-4dd3-99c9-cb8eef0e1b48 Metrics dashboard Target profiles

Baseline: 816693f1296c07b202e401c6bbb6eb5a15ca1dd9 Comparison: a3b37b43389be75fcf841c56247013deb597288e

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

No significant changes in experiment optimization goals

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

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
tcp_syslog_to_blackhole ingress throughput +0.94 [+0.88, +1.00] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.83 [+0.07, +1.59] 1 Logs
idle memory utilization +0.54 [+0.49, +0.58] 1 Logs
pycheck_lots_of_tags % cpu utilization +0.06 [-2.60, +2.72] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.00, +0.00] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
basic_py_check % cpu utilization -0.09 [-2.96, +2.77] 1 Logs
file_tree memory utilization -0.20 [-0.31, -0.08] 1 Logs
otel_to_otel_logs ingress throughput -0.57 [-1.39, +0.26] 1 Logs

Bounds Checks

perf experiment bounds_check_name replicates_passed
idle memory_usage 9/10

Explanation

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".

pr-commenter[bot] avatar Sep 14 '24 01:09 pr-commenter[bot]