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

Add reader/writer dynamic instrumentation configuration manager, and end to end tests #29454

Merged
merged 32 commits into from
Oct 4, 2024

Conversation

grantseltzer
Copy link
Member

What does this PR do?

  • Adds a general purpose reader/writer configuration manager, enabling us to read in configurations via a call to Read(), as well as pass custom io.Writer's for uploading events/diagnostic information.
  • Adds sample-service, a simple program with lots of functions to test GoDI against
  • Adds end to end tests which use the new reader/writer configuration manager, and tests dynamic instrumentation:
    • Build/run the sample-service
    • Goes through a list of fixtures, sets up probes via the config reader and custom writer
    • Compares produced events to expected output

Motivation

Dynamic instrumentation needs to be tested in KMT to ensure stability, expose all features that are not yet supported, and track regressions. Since some tests are expected to fail, this shouldn't block CI.

Describe how to test/QA your changes

Tests should run in KMT.

Possible Drawbacks / Trade-offs

These tests are fully e2e. More tests will be added soon that are more fine-grained.

Copy link
Contributor

@usamasaqib usamasaqib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add DI paths to this list, so the CI detects the changes:
https://github.com/DataDog/datadog-agent/blob/main/.gitlab-ci.yml#L740

@grantseltzer grantseltzer added the team/dynamic-instrumentation Dynamic Instrumentation label Sep 20, 2024
@grantseltzer grantseltzer requested a review from a team as a code owner September 20, 2024 16:42
@pr-commenter
Copy link

pr-commenter bot commented Sep 20, 2024

Gitlab CI Configuration Changes

Modified Jobs

.kitchen_test_system_probe
  .kitchen_test_system_probe:
    after_script:
    - echo "--tags arch:${KITCHEN_ARCH} --tags os:${KITCHEN_PLATFORM} upload_option.os_version_from_name"
      > $CI_PROJECT_DIR/test/kitchen/tags.txt
    - echo "CI_JOB_URL=${CI_JOB_URL}" > $CI_PROJECT_DIR/test/kitchen/job_env.txt
    - echo "CI_JOB_NAME=${CI_JOB_NAME}" >> $CI_PROJECT_DIR/test/kitchen/job_env.txt
    - kitchen_files=$(find $CI_PROJECT_DIR -name "kitchen-rspec-*.xml" -exec basename
      {} \;)
    - find $CI_PROJECT_DIR -name "kitchen-rspec-*.xml" -exec $CI_PROJECT_DIR/test/kitchen/tasks/kitchen_rspec_xml_update.sh
      {} "${CI_JOB_NAME}" \;
    - tar -czvf junit-${CI_JOB_NAME}.tgz -C $CI_PROJECT_DIR/test/kitchen/ ./job_env.txt
      ./tags.txt $kitchen_files
    - $CI_PROJECT_DIR/tools/ci/junit_upload.sh
    artifacts:
      expire_in: 2 weeks
      paths:
      - $CI_PROJECT_DIR/kitchen_logs
      - '**/junit-${CI_JOB_NAME}.tgz'
      when: always
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/dd-agent-testing$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    retry: 1
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    stage: kitchen_testing
    tags:
    - arch:amd64
    timeout: 3h
    variables:
      AGENT_FLAVOR: datadog-agent
      AGENT_MAJOR_VERSION: 7
      CHEF_VERSION: 14.15.6
      DD_PIPELINE_ID: $CI_PIPELINE_ID-fnct
      KUBERNETES_MEMORY_LIMIT: 12Gi
      KUBERNETES_MEMORY_REQUEST: 6Gi
.kmt_run_sysprobe_tests
  .kmt_run_sysprobe_tests:
    artifacts:
      expire_in: 2 weeks
      paths:
      - $DD_AGENT_TESTING_DIR/junit-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/testjson-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/verifier-complexity-$ARCH-$TAG-${TEST_COMPONENT}.tar.gz
      - $CI_PROJECT_DIR/logs
      - $CI_PROJECT_DIR/pcaps
      - $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log
      reports:
        annotations:
        - $EXTERNAL_LINKS_PATH
      when: always
    before_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - echo "CI_JOB_URL=${CI_JOB_URL}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_ID=${CI_JOB_ID}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_NAME=${CI_JOB_NAME}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_STAGE=${CI_JOB_STAGE}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - PLATFORMS_FOR_COMPLEXITY_COLLECTION="amazon_5.4 debian_10 ubuntu_18.04 centos_8
      opensuse_15.3 suse_12.5 fedora_38"
    - "if [ \"${TEST_SET}\" = \"no_usm\" ] && echo \"${PLATFORMS_FOR_COMPLEXITY_COLLECTION}\"\
      \ | grep -qw \"${TAG}\" ; then\n  export COLLECT_COMPLEXITY=yes\nfi\n"
    - echo "COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY}"
    retry:
      exit_codes: 42
      max: 2
      when:
      - job_execution_timeout
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
      - scheduler_failure
      - stale_schedule
      - data_integrity_failure
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - INSTANCE_IP=$(jq --exit-status --arg ARCH $ARCH -r '.[$ARCH].ip' $CI_PROJECT_DIR/stack.output)
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - RUNNING_INSTANCES=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_PIPELINE $FILTER_TEST_COMPONENT "Name=private-ip-address,Values=$INSTANCE_IP"
      --output text --query $QUERY_INSTANCE_IDS | wc -l )
    - "if [ $RUNNING_INSTANCES -eq \"0\" ]; then\n  echo \"These jobs do not permit\
      \ retries. The go tests are retried a user-specified number of times automatically.\
      \ In order to re-run the tests, you must trigger the pipeline again\"\n  'false'\n\
      fi\n"
    - MICRO_VM_IP=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].ip' $CI_PROJECT_DIR/stack.output)
    - MICRO_VM_NAME=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].id' $CI_PROJECT_DIR/stack.output)
    - GO_VERSION=$(inv go-version)
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp "$DD_AGENT_TESTING_DIR/job_env.txt" "metal_instance:/home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt"
    - ssh metal_instance "scp /home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt ${MICRO_VM_IP}:/job_env.txt"
    - NESTED_VM_CMD="/home/ubuntu/connector -host ${MICRO_VM_IP} -user root -ssh-file
      /home/kernel-version-testing/ddvm_rsa -vm-cmd 'CI=true /root/fetch_dependencies.sh
      ${ARCH} && COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY} /opt/micro-vm-init.sh -test-tools
      /opt/testing-tools -retry ${RETRY} -test-root /opt/${TEST_COMPONENT}-tests -packages-run-config
      /opt/${TEST_SET}.json'"
    - $CI_PROJECT_DIR/connector-$ARCH -host $INSTANCE_IP -user ubuntu -ssh-file $AWS_EC2_SSH_KEY_FILE
      -vm-cmd "${NESTED_VM_CMD}" -send-env-vars DD_API_KEY
    - ssh metal_instance "ssh ${MICRO_VM_IP} '/opt/testing-tools/test-json-review -flakes
      /opt/testing-tools/flakes.yaml -codeowners /opt/testing-tools/CODEOWNERS -test-root
      /opt/${TEST_COMPONENT}-tests'"
    - '[ ! -f $CI_PROJECT_DIR/daemon-${ARCH}.log ] && scp metal_instance:/home/ubuntu/daemon.log
      $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log'
    stage: kernel_matrix_testing_system_probe
    timeout: 1h 30m
    variables:
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json
      RETRY: 2
      TEST_COMPONENT: system-probe
.kmt_sysprobe_cleanup
  .kmt_sysprobe_cleanup:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    before_script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - inv kmt.wait-for-setup-job --pipeline-id $CI_PIPELINE_ID --arch $ARCH --component
      $TEST_COMPONENT
    - aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_PIPELINE
      $FILTER_ARCH $FILTER_INSTANCE_TYPE $FILTER_TEST_COMPONENT --output json --query
      $QUERY_INSTANCE_IDS | tee -a instance.json
    - INSTANCE_ID="$(jq -r '.[0][0]' < instance.json)"
    - echo ${INSTANCE_ID}
    - "if [[ \"${INSTANCE_ID}\" != \"\" ]] && [[ \"${INSTANCE_ID}\" != \"null\" ]];\
      \ then\n  aws ec2 terminate-instances --instance-ids \"${INSTANCE_ID}\"\nfi\n"
    stage: kernel_matrix_testing_cleanup
    tags:
    - arch:amd64
    variables:
      TEST_COMPONENT: system-probe
.on_system_probe_or_e2e_changes_or_manual
  .on_system_probe_or_e2e_changes_or_manual:
  - if: $CI_COMMIT_BRANCH == "main"
  - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
    when: never
  - if: $RUN_KMT_TESTS == 'on'
  - changes:
      compare_to: main
      paths:
      - pkg/collector/corechecks/ebpf/**/*
      - pkg/collector/corechecks/servicediscovery/module/*
      - pkg/ebpf/**/*
      - pkg/network/**/*
      - pkg/process/monitor/*
      - pkg/util/kernel/**/*
+     - pkg/dynamicinstrumentation/**/*
      - .gitlab/kernel_matrix_testing/system_probe.yml
      - .gitlab/kernel_matrix_testing/common.yml
      - .gitlab/source_test/ebpf.yml
      - test/new-e2e/system-probe/**/*
      - test/new-e2e/scenarios/system-probe/**/*
      - test/new-e2e/pkg/runner/**/*
      - test/new-e2e/pkg/utils/**/*
      - test/new-e2e/go.mod
      - tasks/system_probe.py
      - tasks/kmt.py
      - tasks/kernel_matrix_testing/*
.pull_test_dockers
  .pull_test_dockers:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      expire_in: 1 day
      paths:
      - $KMT_DOCKERS
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/docker_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs: []
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - DOCKER_LOGIN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO user)
      || exit $?
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO token | crane auth
      login --username "$DOCKER_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
    - EXIT="${PIPESTATUS[0]}"; if [ $EXIT -ne 0 ]; then echo "Unable to locate credentials
      needs gitlab runner restart"; exit $EXIT; fi
    - mkdir $KMT_DOCKERS
    - inv -e system-probe.save-test-dockers --use-crane --output-dir $KMT_DOCKERS --arch
      $ARCH
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      KMT_DOCKERS: $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH
.system_probe_change_paths
  .system_probe_change_paths:
  - pkg/collector/corechecks/ebpf/**/*
  - pkg/collector/corechecks/servicediscovery/module/*
  - pkg/ebpf/**/*
  - pkg/network/**/*
  - pkg/process/monitor/*
  - pkg/util/kernel/**/*
+ - pkg/dynamicinstrumentation/**/*
  - .gitlab/kernel_matrix_testing/system_probe.yml
  - .gitlab/kernel_matrix_testing/common.yml
  - .gitlab/source_test/ebpf.yml
  - test/new-e2e/system-probe/**/*
  - test/new-e2e/scenarios/system-probe/**/*
  - test/new-e2e/pkg/runner/**/*
  - test/new-e2e/pkg/utils/**/*
  - test/new-e2e/go.mod
  - tasks/system_probe.py
  - tasks/kmt.py
  - tasks/kernel_matrix_testing/*
.upload_sysprobe_tests
  .upload_sysprobe_tests:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      paths:
      - $CI_PROJECT_DIR/connector-${ARCH}
      when: always
    before_script:
    - mkdir -p $GOPATH/pkg/mod/cache && tar xJf modcache.tar.xz -C $GOPATH/pkg/mod/cache
    - rm -f modcache.tar.xz
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - pushd $CI_PROJECT_DIR/kmt-deps/ci/$ARCH
    - tar czvf $TEST_ARCHIVE_NAME opt
    - popd
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/$TEST_ARCHIVE_NAME metal_instance:/opt/kernel-version-testing/
    - pushd $CI_PROJECT_DIR/test/new-e2e
    - go build -o $CI_PROJECT_DIR/connector-${ARCH} $CI_PROJECT_DIR/test/new-e2e/system-probe/connector/main.go
    - popd
    - scp $CI_PROJECT_DIR/connector-${ARCH} metal_instance:/home/ubuntu/connector
    stage: kernel_matrix_testing_prepare
    variables:
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      TEST_ARCHIVE_NAME: tests-$ARCH.tar.gz
      TEST_COMPONENT: system-probe
cleanup_kitchen_functional_test
  cleanup_kitchen_functional_test:
    allow_failure: true
    before_script: null
    dependencies: []
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/dd-agent-testing$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - cd $DD_AGENT_TESTING_DIR
    - tasks/clean.sh
    stage: functional_test_cleanup
    tags:
    - arch:amd64
    variables:
      DD_PIPELINE_ID: $CI_PIPELINE_ID-fnct
kmt_run_sysprobe_tests_arm64
  kmt_run_sysprobe_tests_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - export MICRO_VM_IP=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].ip' $CI_PROJECT_DIR/stack.output)
    - mkdir -p $CI_PROJECT_DIR/logs
    - ssh metal_instance "ssh ${MICRO_VM_IP} \"journalctl -u setup-ddvm.service\"" >
      $CI_PROJECT_DIR/logs/setup-ddvm.log || true
    - cat $CI_PROJECT_DIR/logs/setup-ddvm.log || true
    - ssh metal_instance "ssh ${MICRO_VM_IP} \"systemctl is-active setup-ddvm.service\""
      | tee $CI_PROJECT_DIR/logs/setup-ddvm.status || true
    - ssh metal_instance "scp ${MICRO_VM_IP}:/ci-visibility/junit.tar.gz /home/ubuntu/junit-${ARCH}-${TAG}-${TEST_SET}.tar.gz"
      || true
    - scp "metal_instance:/home/ubuntu/junit-${ARCH}-${TAG}-${TEST_SET}.tar.gz" $DD_AGENT_TESTING_DIR/
      || true
    - ssh metal_instance "scp ${MICRO_VM_IP}:/ci-visibility/testjson.tar.gz /home/ubuntu/testjson-${ARCH}-${TAG}-${TEST_SET}.tar.gz"
      || true
    - scp "metal_instance:/home/ubuntu/testjson-${ARCH}-${TAG}-${TEST_SET}.tar.gz" $DD_AGENT_TESTING_DIR/
      || true
    - ssh metal_instance "scp -r ${MICRO_VM_IP}:/tmp/test_pcaps /home/ubuntu/test_pcaps-${ARCH}-${TAG}-${TEST_SET}"
      || true
    - mkdir -p "$CI_PROJECT_DIR/pcaps" && scp -r "metal_instance:/home/ubuntu/test_pcaps-${ARCH}-${TAG}-${TEST_SET}"
      "$CI_PROJECT_DIR/pcaps/test_pcaps-${ARCH}-${TAG}-${TEST_SET}" || true
    - PLATFORMS_FOR_COMPLEXITY_COLLECTION="amazon_5.4 debian_10 ubuntu_18.04 centos_8
      opensuse_15.3 suse_12.5 fedora_38"
    - "if [ \"${TEST_SET}\" = \"no_usm\" ] && echo \"${PLATFORMS_FOR_COMPLEXITY_COLLECTION}\"\
      \ | grep -qw \"${TAG}\" ; then\n  export COLLECT_COMPLEXITY=yes\nfi\n"
    - echo "COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY}"
    - "if [ \"${COLLECT_COMPLEXITY}\" = \"yes\" ]; then\n  ssh metal_instance \"scp\
      \ ${MICRO_VM_IP}:/verifier-complexity.tar.gz /home/ubuntu/verifier-complexity-${ARCH}-${TAG}-${TEST_COMPONENT}.tar.gz\"\
      \ || true\n  scp \"metal_instance:/home/ubuntu/verifier-complexity-${ARCH}-${TAG}-${TEST_COMPONENT}.tar.gz\"\
      \ $DD_AGENT_TESTING_DIR/ || true\nfi\n"
    - inv -e kmt.tag-ci-job
    artifacts:
      expire_in: 2 weeks
      paths:
      - $DD_AGENT_TESTING_DIR/junit-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/testjson-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/verifier-complexity-$ARCH-$TAG-${TEST_COMPONENT}.tar.gz
      - $CI_PROJECT_DIR/logs
      - $CI_PROJECT_DIR/pcaps
      - $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log
      reports:
        annotations:
        - $EXTERNAL_LINKS_PATH
      when: always
    before_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - echo "CI_JOB_URL=${CI_JOB_URL}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_ID=${CI_JOB_ID}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_NAME=${CI_JOB_NAME}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_STAGE=${CI_JOB_STAGE}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - PLATFORMS_FOR_COMPLEXITY_COLLECTION="amazon_5.4 debian_10 ubuntu_18.04 centos_8
      opensuse_15.3 suse_12.5 fedora_38"
    - "if [ \"${TEST_SET}\" = \"no_usm\" ] && echo \"${PLATFORMS_FOR_COMPLEXITY_COLLECTION}\"\
      \ | grep -qw \"${TAG}\" ; then\n  export COLLECT_COMPLEXITY=yes\nfi\n"
    - echo "COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY}"
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_arm64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - kmt_setup_env_sysprobe_arm64
    - upload_dependencies_sysprobe_arm64
    - upload_sysprobe_tests_arm64
    - upload_minimized_btfs_sysprobe_arm64
    parallel:
      matrix:
      - TAG:
        - ubuntu_18.04
        - ubuntu_20.04
        - ubuntu_22.04
        - ubuntu_23.10
        - amazon_4.14
        - amazon_5.4
        - amazon_5.10
        - amazon_2023
        - fedora_37
        - fedora_38
        - debian_10
        - debian_11
        - debian_12
        - centos_7.9
        - centos_8
        TEST_SET:
        - only_usm
        - no_usm
    retry:
      exit_codes:
      - 42
      max: 2
      when:
      - job_execution_timeout
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
      - scheduler_failure
      - stale_schedule
      - data_integrity_failure
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - INSTANCE_IP=$(jq --exit-status --arg ARCH $ARCH -r '.[$ARCH].ip' $CI_PROJECT_DIR/stack.output)
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - RUNNING_INSTANCES=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_PIPELINE $FILTER_TEST_COMPONENT "Name=private-ip-address,Values=$INSTANCE_IP"
      --output text --query $QUERY_INSTANCE_IDS | wc -l )
    - "if [ $RUNNING_INSTANCES -eq \"0\" ]; then\n  echo \"These jobs do not permit\
      \ retries. The go tests are retried a user-specified number of times automatically.\
      \ In order to re-run the tests, you must trigger the pipeline again\"\n  'false'\n\
      fi\n"
    - MICRO_VM_IP=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].ip' $CI_PROJECT_DIR/stack.output)
    - MICRO_VM_NAME=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].id' $CI_PROJECT_DIR/stack.output)
    - GO_VERSION=$(inv go-version)
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp "$DD_AGENT_TESTING_DIR/job_env.txt" "metal_instance:/home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt"
    - ssh metal_instance "scp /home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt ${MICRO_VM_IP}:/job_env.txt"
    - NESTED_VM_CMD="/home/ubuntu/connector -host ${MICRO_VM_IP} -user root -ssh-file
      /home/kernel-version-testing/ddvm_rsa -vm-cmd 'CI=true /root/fetch_dependencies.sh
      ${ARCH} && COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY} /opt/micro-vm-init.sh -test-tools
      /opt/testing-tools -retry ${RETRY} -test-root /opt/${TEST_COMPONENT}-tests -packages-run-config
      /opt/${TEST_SET}.json'"
    - $CI_PROJECT_DIR/connector-$ARCH -host $INSTANCE_IP -user ubuntu -ssh-file $AWS_EC2_SSH_KEY_FILE
      -vm-cmd "${NESTED_VM_CMD}" -send-env-vars DD_API_KEY
    - ssh metal_instance "ssh ${MICRO_VM_IP} '/opt/testing-tools/test-json-review -flakes
      /opt/testing-tools/flakes.yaml -codeowners /opt/testing-tools/CODEOWNERS -test-root
      /opt/${TEST_COMPONENT}-tests'"
    - '[ ! -f $CI_PROJECT_DIR/daemon-${ARCH}.log ] && scp metal_instance:/home/ubuntu/daemon.log
      $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log'
    stage: kernel_matrix_testing_system_probe
    tags:
    - arch:arm64
    timeout: 1h 30m
    variables:
      ARCH: arm64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json
      RETRY: 2
      TEST_COMPONENT: system-probe
kmt_run_sysprobe_tests_x64
  kmt_run_sysprobe_tests_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - export MICRO_VM_IP=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].ip' $CI_PROJECT_DIR/stack.output)
    - mkdir -p $CI_PROJECT_DIR/logs
    - ssh metal_instance "ssh ${MICRO_VM_IP} \"journalctl -u setup-ddvm.service\"" >
      $CI_PROJECT_DIR/logs/setup-ddvm.log || true
    - cat $CI_PROJECT_DIR/logs/setup-ddvm.log || true
    - ssh metal_instance "ssh ${MICRO_VM_IP} \"systemctl is-active setup-ddvm.service\""
      | tee $CI_PROJECT_DIR/logs/setup-ddvm.status || true
    - ssh metal_instance "scp ${MICRO_VM_IP}:/ci-visibility/junit.tar.gz /home/ubuntu/junit-${ARCH}-${TAG}-${TEST_SET}.tar.gz"
      || true
    - scp "metal_instance:/home/ubuntu/junit-${ARCH}-${TAG}-${TEST_SET}.tar.gz" $DD_AGENT_TESTING_DIR/
      || true
    - ssh metal_instance "scp ${MICRO_VM_IP}:/ci-visibility/testjson.tar.gz /home/ubuntu/testjson-${ARCH}-${TAG}-${TEST_SET}.tar.gz"
      || true
    - scp "metal_instance:/home/ubuntu/testjson-${ARCH}-${TAG}-${TEST_SET}.tar.gz" $DD_AGENT_TESTING_DIR/
      || true
    - ssh metal_instance "scp -r ${MICRO_VM_IP}:/tmp/test_pcaps /home/ubuntu/test_pcaps-${ARCH}-${TAG}-${TEST_SET}"
      || true
    - mkdir -p "$CI_PROJECT_DIR/pcaps" && scp -r "metal_instance:/home/ubuntu/test_pcaps-${ARCH}-${TAG}-${TEST_SET}"
      "$CI_PROJECT_DIR/pcaps/test_pcaps-${ARCH}-${TAG}-${TEST_SET}" || true
    - PLATFORMS_FOR_COMPLEXITY_COLLECTION="amazon_5.4 debian_10 ubuntu_18.04 centos_8
      opensuse_15.3 suse_12.5 fedora_38"
    - "if [ \"${TEST_SET}\" = \"no_usm\" ] && echo \"${PLATFORMS_FOR_COMPLEXITY_COLLECTION}\"\
      \ | grep -qw \"${TAG}\" ; then\n  export COLLECT_COMPLEXITY=yes\nfi\n"
    - echo "COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY}"
    - "if [ \"${COLLECT_COMPLEXITY}\" = \"yes\" ]; then\n  ssh metal_instance \"scp\
      \ ${MICRO_VM_IP}:/verifier-complexity.tar.gz /home/ubuntu/verifier-complexity-${ARCH}-${TAG}-${TEST_COMPONENT}.tar.gz\"\
      \ || true\n  scp \"metal_instance:/home/ubuntu/verifier-complexity-${ARCH}-${TAG}-${TEST_COMPONENT}.tar.gz\"\
      \ $DD_AGENT_TESTING_DIR/ || true\nfi\n"
    - inv -e kmt.tag-ci-job
    - $CI_PROJECT_DIR/tools/ci/junit_upload.sh "$DD_AGENT_TESTING_DIR/junit-*.tar.gz"
    artifacts:
      expire_in: 2 weeks
      paths:
      - $DD_AGENT_TESTING_DIR/junit-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/testjson-$ARCH-$TAG-$TEST_SET.tar.gz
      - $DD_AGENT_TESTING_DIR/verifier-complexity-$ARCH-$TAG-${TEST_COMPONENT}.tar.gz
      - $CI_PROJECT_DIR/logs
      - $CI_PROJECT_DIR/pcaps
      - $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log
      reports:
        annotations:
        - $EXTERNAL_LINKS_PATH
      when: always
    before_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - echo "CI_JOB_URL=${CI_JOB_URL}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_ID=${CI_JOB_ID}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_NAME=${CI_JOB_NAME}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - echo "CI_JOB_STAGE=${CI_JOB_STAGE}" >> $DD_AGENT_TESTING_DIR/job_env.txt
    - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - PLATFORMS_FOR_COMPLEXITY_COLLECTION="amazon_5.4 debian_10 ubuntu_18.04 centos_8
      opensuse_15.3 suse_12.5 fedora_38"
    - "if [ \"${TEST_SET}\" = \"no_usm\" ] && echo \"${PLATFORMS_FOR_COMPLEXITY_COLLECTION}\"\
      \ | grep -qw \"${TAG}\" ; then\n  export COLLECT_COMPLEXITY=yes\nfi\n"
    - echo "COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY}"
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - kmt_setup_env_sysprobe_x64
    - upload_dependencies_sysprobe_x64
    - upload_sysprobe_tests_x64
    - upload_minimized_btfs_sysprobe_x64
    parallel:
      matrix:
      - TAG:
        - ubuntu_16.04
        - ubuntu_18.04
        - ubuntu_20.04
        - ubuntu_22.04
        - ubuntu_23.10
        - amazon_4.14
        - amazon_5.4
        - amazon_5.10
        - amazon_2023
        - fedora_37
        - fedora_38
        - debian_9
        - debian_10
        - debian_11
        - debian_12
        - centos_7.9
        - centos_8
        TEST_SET:
        - only_usm
        - no_usm
    retry:
      exit_codes:
      - 42
      max: 2
      when:
      - job_execution_timeout
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
      - scheduler_failure
      - stale_schedule
      - data_integrity_failure
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - INSTANCE_IP=$(jq --exit-status --arg ARCH $ARCH -r '.[$ARCH].ip' $CI_PROJECT_DIR/stack.output)
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - RUNNING_INSTANCES=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_PIPELINE $FILTER_TEST_COMPONENT "Name=private-ip-address,Values=$INSTANCE_IP"
      --output text --query $QUERY_INSTANCE_IDS | wc -l )
    - "if [ $RUNNING_INSTANCES -eq \"0\" ]; then\n  echo \"These jobs do not permit\
      \ retries. The go tests are retried a user-specified number of times automatically.\
      \ In order to re-run the tests, you must trigger the pipeline again\"\n  'false'\n\
      fi\n"
    - MICRO_VM_IP=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].ip' $CI_PROJECT_DIR/stack.output)
    - MICRO_VM_NAME=$(jq --exit-status --arg TAG $TAG --arg ARCH $ARCH --arg TEST_SET
      $TEST_SET -r '.[$ARCH].microvms | map(select(."vmset-tags"| index($TEST_SET)))
      | map(select(.tag==$TAG)) | .[].id' $CI_PROJECT_DIR/stack.output)
    - GO_VERSION=$(inv go-version)
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp "$DD_AGENT_TESTING_DIR/job_env.txt" "metal_instance:/home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt"
    - ssh metal_instance "scp /home/ubuntu/job_env-${ARCH}-${TAG}-${TEST_SET}.txt ${MICRO_VM_IP}:/job_env.txt"
    - NESTED_VM_CMD="/home/ubuntu/connector -host ${MICRO_VM_IP} -user root -ssh-file
      /home/kernel-version-testing/ddvm_rsa -vm-cmd 'CI=true /root/fetch_dependencies.sh
      ${ARCH} && COLLECT_COMPLEXITY=${COLLECT_COMPLEXITY} /opt/micro-vm-init.sh -test-tools
      /opt/testing-tools -retry ${RETRY} -test-root /opt/${TEST_COMPONENT}-tests -packages-run-config
      /opt/${TEST_SET}.json'"
    - $CI_PROJECT_DIR/connector-$ARCH -host $INSTANCE_IP -user ubuntu -ssh-file $AWS_EC2_SSH_KEY_FILE
      -vm-cmd "${NESTED_VM_CMD}" -send-env-vars DD_API_KEY
    - ssh metal_instance "ssh ${MICRO_VM_IP} '/opt/testing-tools/test-json-review -flakes
      /opt/testing-tools/flakes.yaml -codeowners /opt/testing-tools/CODEOWNERS -test-root
      /opt/${TEST_COMPONENT}-tests'"
    - '[ ! -f $CI_PROJECT_DIR/daemon-${ARCH}.log ] && scp metal_instance:/home/ubuntu/daemon.log
      $CI_PROJECT_DIR/vm-metrics-daemon-${ARCH}.log'
    stage: kernel_matrix_testing_system_probe
    tags:
    - arch:amd64
    timeout: 1h 30m
    variables:
      ARCH: x86_64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json
      RETRY: 2
      TEST_COMPONENT: system-probe
kmt_setup_env_sysprobe_arm64
  kmt_setup_env_sysprobe_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - export AWS_PROFILE=agent-qa-ci
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - mkdir -p $CI_PROJECT_DIR/libvirt/log/$ARCH $CI_PROJECT_DIR/libvirt/xml $CI_PROJECT_DIR/libvirt/qemu
      $CI_PROJECT_DIR/libvirt/dnsmasq
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "sudo virsh list --name | grep -v -E '^$' | xargs -I '{}' sh -c \"sudo virsh dumpxml
      '{}' > /tmp/ddvm-xml-'{}'.txt\""
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "sudo virsh list --name | xargs -I '{}' sh -c \"sudo cp /var/log/libvirt/qemu/'{}'.log
      /tmp/qemu-ddvm-'{}'.log && sudo chown 1000:1000 /tmp/qemu-ddvm*\""
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "mkdir /tmp/dnsmasq && sudo cp /var/lib/libvirt/dnsmasq/* /tmp/dnsmasq/ && sudo
      chown 1000:1000 /tmp/dnsmasq/*"
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/ddvm-*.log"
      $CI_PROJECT_DIR/libvirt/log
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/ddvm-xml-*"
      $CI_PROJECT_DIR/libvirt/xml
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/qemu-ddvm-*.log"
      $CI_PROJECT_DIR/libvirt/qemu
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/dnsmasq/*"
      $CI_PROJECT_DIR/libvirt/dnsmasq
    - "GO_ARCH=$ARCH\nif [ \"${ARCH}\" == \"x86_64\" ]; then\n  GO_ARCH=amd64\nfi\n"
    - cd test/new-e2e && GOOS=linux GOARCH="${GO_ARCH}" go build system-probe/vm-metrics/vm-metrics.go
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE $CI_PROJECT_DIR/test/new-e2e/vm-metrics
      "ubuntu@$INSTANCE_IP:/home/ubuntu/vm-metrics"
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "/home/ubuntu/vm-metrics -statsd-host=127.0.0.1 -statsd-port=8125 -libvirt-uri=/var/run/libvirt/libvirt-sock-ro
      --tag \"arch:${ARCH}\" --tag \"test-component:${TEST_COMPONENT}\" --tag \"ci-pipeline-id:${CI_PIPELINE_ID}\"
      --daemon -log-file /home/ubuntu/daemon.log"
    - inv -e kmt.tag-ci-job
    artifacts:
      paths:
      - $CI_PROJECT_DIR/stack.output
      - $CI_PROJECT_DIR/libvirt
      - $VMCONFIG_FILE
      reports:
        annotations:
        - $EXTERNAL_LINKS_PATH
      when: always
    before_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - mkdir -p $GOPATH/pkg/mod/cache && tar xJf modcache.tar.xz -C $GOPATH/pkg/mod/cache
    - rm -f modcache.tar.xz
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH || true
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs:
    - go_deps
    - go_tools_deps
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - echo "s3://dd-pulumi-state?region=us-east-1&awssdk=v2&profile=$AWS_PROFILE" >
      $STACK_DIR
    - pulumi login $(cat $STACK_DIR | tr -d '\n')
    - inv -e kmt.gen-config --ci --arch=$ARCH --output-file=$VMCONFIG_FILE --sets=$TEST_SETS
      --vmconfig-template=$TEST_COMPONENT --memory=12288
    - inv -e system-probe.start-microvms --provision-instance --provision-microvms --vmconfig=$VMCONFIG_FILE
      $INSTANCE_TYPE_ARG $AMI_ID_ARG --ssh-key-name=$AWS_EC2_SSH_KEY_NAME --ssh-key-path=$AWS_EC2_SSH_KEY_FILE
      --infra-env=$INFRA_ENV --stack-name=kernel-matrix-testing-${TEST_COMPONENT}-${ARCH}-${CI_PIPELINE_ID}
      --run-agent
    - jq "." $CI_PROJECT_DIR/stack.output
    - pulumi logout
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      AMI_ID_ARG: --arm-ami-id=$KERNEL_MATRIX_TESTING_ARM_AMI_ID
      ARCH: arm64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      AWS_EC2_SSH_KEY_NAME: datadog-agent-ci
      AWS_REGION: us-east-1
      EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json
      INFRA_ENV: aws/agent-qa
      INSTANCE_TYPE: m6gd.metal
      INSTANCE_TYPE_ARG: --instance-type-arm=$INSTANCE_TYPE
      KITCHEN_EC2_REGION: us-east-1
      KITCHEN_EC2_SG_IDS: sg-019917348cb0eb7e7
      KITCHEN_EC2_SUBNET: subnet-05d7c6b1b5cfea811
      KUBERNETES_MEMORY_LIMIT: 16Gi
      KUBERNETES_MEMORY_REQUEST: 12Gi
      LibvirtSSHKey: $CI_PROJECT_DIR/libvirt_rsa-arm
      PIPELINE_ID: $CI_PIPELINE_ID
      RESOURCE_TAGS: instance-type:${INSTANCE_TYPE},arch:${ARCH},test-component:${TEST_COMPONENT},git-branch:${CI_COMMIT_REF_NAME}
      STACK_DIR: $CI_PROJECT_DIR/stack.dir
      TEAM: ebpf-platform
      TEST_COMPONENT: system-probe
      TEST_SETS: only_usm,no_usm
      VMCONFIG_FILE: ${CI_PROJECT_DIR}/vmconfig-${CI_PIPELINE_ID}-${ARCH}.json
kmt_setup_env_sysprobe_x64
  kmt_setup_env_sysprobe_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - export AWS_PROFILE=agent-qa-ci
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - mkdir -p $CI_PROJECT_DIR/libvirt/log/$ARCH $CI_PROJECT_DIR/libvirt/xml $CI_PROJECT_DIR/libvirt/qemu
      $CI_PROJECT_DIR/libvirt/dnsmasq
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "sudo virsh list --name | grep -v -E '^$' | xargs -I '{}' sh -c \"sudo virsh dumpxml
      '{}' > /tmp/ddvm-xml-'{}'.txt\""
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "sudo virsh list --name | xargs -I '{}' sh -c \"sudo cp /var/log/libvirt/qemu/'{}'.log
      /tmp/qemu-ddvm-'{}'.log && sudo chown 1000:1000 /tmp/qemu-ddvm*\""
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "mkdir /tmp/dnsmasq && sudo cp /var/lib/libvirt/dnsmasq/* /tmp/dnsmasq/ && sudo
      chown 1000:1000 /tmp/dnsmasq/*"
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/ddvm-*.log"
      $CI_PROJECT_DIR/libvirt/log
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/ddvm-xml-*"
      $CI_PROJECT_DIR/libvirt/xml
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/qemu-ddvm-*.log"
      $CI_PROJECT_DIR/libvirt/qemu
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP:/tmp/dnsmasq/*"
      $CI_PROJECT_DIR/libvirt/dnsmasq
    - "GO_ARCH=$ARCH\nif [ \"${ARCH}\" == \"x86_64\" ]; then\n  GO_ARCH=amd64\nfi\n"
    - cd test/new-e2e && GOOS=linux GOARCH="${GO_ARCH}" go build system-probe/vm-metrics/vm-metrics.go
    - scp -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE $CI_PROJECT_DIR/test/new-e2e/vm-metrics
      "ubuntu@$INSTANCE_IP:/home/ubuntu/vm-metrics"
    - ssh -o StrictHostKeyChecking=no -i $AWS_EC2_SSH_KEY_FILE "ubuntu@$INSTANCE_IP"
      "/home/ubuntu/vm-metrics -statsd-host=127.0.0.1 -statsd-port=8125 -libvirt-uri=/var/run/libvirt/libvirt-sock-ro
      --tag \"arch:${ARCH}\" --tag \"test-component:${TEST_COMPONENT}\" --tag \"ci-pipeline-id:${CI_PIPELINE_ID}\"
      --daemon -log-file /home/ubuntu/daemon.log"
    - inv -e kmt.tag-ci-job
    artifacts:
      paths:
      - $CI_PROJECT_DIR/stack.output
      - $CI_PROJECT_DIR/libvirt
      - $VMCONFIG_FILE
      reports:
        annotations:
        - $EXTERNAL_LINKS_PATH
      when: always
    before_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - mkdir -p $GOPATH/pkg/mod/cache && tar xJf modcache.tar.xz -C $GOPATH/pkg/mod/cache
    - rm -f modcache.tar.xz
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH || true
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs:
    - go_deps
    - go_tools_deps
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - echo "s3://dd-pulumi-state?region=us-east-1&awssdk=v2&profile=$AWS_PROFILE" >
      $STACK_DIR
    - pulumi login $(cat $STACK_DIR | tr -d '\n')
    - inv -e kmt.gen-config --ci --arch=$ARCH --output-file=$VMCONFIG_FILE --sets=$TEST_SETS
      --vmconfig-template=$TEST_COMPONENT --memory=12288
    - inv -e system-probe.start-microvms --provision-instance --provision-microvms --vmconfig=$VMCONFIG_FILE
      $INSTANCE_TYPE_ARG $AMI_ID_ARG --ssh-key-name=$AWS_EC2_SSH_KEY_NAME --ssh-key-path=$AWS_EC2_SSH_KEY_FILE
      --infra-env=$INFRA_ENV --stack-name=kernel-matrix-testing-${TEST_COMPONENT}-${ARCH}-${CI_PIPELINE_ID}
      --run-agent
    - jq "." $CI_PROJECT_DIR/stack.output
    - pulumi logout
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      AMI_ID_ARG: --x86-ami-id=$KERNEL_MATRIX_TESTING_X86_AMI_ID
      ARCH: x86_64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      AWS_EC2_SSH_KEY_NAME: datadog-agent-ci
      AWS_REGION: us-east-1
      EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json
      INFRA_ENV: aws/agent-qa
      INSTANCE_TYPE: m5d.metal
      INSTANCE_TYPE_ARG: --instance-type-x86=$INSTANCE_TYPE
      KITCHEN_EC2_REGION: us-east-1
      KITCHEN_EC2_SG_IDS: sg-019917348cb0eb7e7
      KITCHEN_EC2_SUBNET: subnet-05d7c6b1b5cfea811
      KUBERNETES_MEMORY_LIMIT: 16Gi
      KUBERNETES_MEMORY_REQUEST: 12Gi
      LibvirtSSHKey: $CI_PROJECT_DIR/libvirt_rsa-x86
      PIPELINE_ID: $CI_PIPELINE_ID
      RESOURCE_TAGS: instance-type:${INSTANCE_TYPE},arch:${ARCH},test-component:${TEST_COMPONENT},git-branch:${CI_COMMIT_REF_NAME}
      STACK_DIR: $CI_PROJECT_DIR/stack.dir
      TEAM: ebpf-platform
      TEST_COMPONENT: system-probe
      TEST_SETS: only_usm,no_usm
      VMCONFIG_FILE: ${CI_PROJECT_DIR}/vmconfig-${CI_PIPELINE_ID}-${ARCH}.json
kmt_sysprobe_cleanup_arm64
  kmt_sysprobe_cleanup_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    before_script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs:
    - kmt_setup_env_sysprobe_arm64
    - kmt_run_sysprobe_tests_arm64
    - upload_minimized_btfs_sysprobe_arm64
    - upload_sysprobe_tests_arm64
    - upload_dependencies_sysprobe_arm64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - inv kmt.wait-for-setup-job --pipeline-id $CI_PIPELINE_ID --arch $ARCH --component
      $TEST_COMPONENT
    - aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_PIPELINE
      $FILTER_ARCH $FILTER_INSTANCE_TYPE $FILTER_TEST_COMPONENT --output json --query
      $QUERY_INSTANCE_IDS | tee -a instance.json
    - INSTANCE_ID="$(jq -r '.[0][0]' < instance.json)"
    - echo ${INSTANCE_ID}
    - "if [[ \"${INSTANCE_ID}\" != \"\" ]] && [[ \"${INSTANCE_ID}\" != \"null\" ]];\
      \ then\n  aws ec2 terminate-instances --instance-ids \"${INSTANCE_ID}\"\nfi\n"
    stage: kernel_matrix_testing_cleanup
    tags:
    - arch:amd64
    variables:
      ARCH: arm64
      INSTANCE_TYPE: m6gd.metal
      TEST_COMPONENT: system-probe
    when: always
kmt_sysprobe_cleanup_arm64_manual
  kmt_sysprobe_cleanup_arm64_manual:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    allow_failure: true
    before_script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs: []
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - inv kmt.wait-for-setup-job --pipeline-id $CI_PIPELINE_ID --arch $ARCH --component
      $TEST_COMPONENT
    - aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_PIPELINE
      $FILTER_ARCH $FILTER_INSTANCE_TYPE $FILTER_TEST_COMPONENT --output json --query
      $QUERY_INSTANCE_IDS | tee -a instance.json
    - INSTANCE_ID="$(jq -r '.[0][0]' < instance.json)"
    - echo ${INSTANCE_ID}
    - "if [[ \"${INSTANCE_ID}\" != \"\" ]] && [[ \"${INSTANCE_ID}\" != \"null\" ]];\
      \ then\n  aws ec2 terminate-instances --instance-ids \"${INSTANCE_ID}\"\nfi\n"
    stage: kernel_matrix_testing_cleanup
    tags:
    - arch:amd64
    variables:
      ARCH: arm64
      INSTANCE_TYPE: m6gd.metal
      TEST_COMPONENT: system-probe
    when: manual
kmt_sysprobe_cleanup_x64
  kmt_sysprobe_cleanup_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    before_script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs:
    - kmt_setup_env_sysprobe_x64
    - kmt_run_sysprobe_tests_x64
    - upload_minimized_btfs_sysprobe_x64
    - upload_sysprobe_tests_x64
    - upload_dependencies_sysprobe_x64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - inv kmt.wait-for-setup-job --pipeline-id $CI_PIPELINE_ID --arch $ARCH --component
      $TEST_COMPONENT
    - aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_PIPELINE
      $FILTER_ARCH $FILTER_INSTANCE_TYPE $FILTER_TEST_COMPONENT --output json --query
      $QUERY_INSTANCE_IDS | tee -a instance.json
    - INSTANCE_ID="$(jq -r '.[0][0]' < instance.json)"
    - echo ${INSTANCE_ID}
    - "if [[ \"${INSTANCE_ID}\" != \"\" ]] && [[ \"${INSTANCE_ID}\" != \"null\" ]];\
      \ then\n  aws ec2 terminate-instances --instance-ids \"${INSTANCE_ID}\"\nfi\n"
    stage: kernel_matrix_testing_cleanup
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      INSTANCE_TYPE: m5d.metal
      TEST_COMPONENT: system-probe
    when: always
kmt_sysprobe_cleanup_x64_manual
  kmt_sysprobe_cleanup_x64_manual:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    allow_failure: true
    before_script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_SCHEDULER_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
    needs: []
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - inv kmt.wait-for-setup-job --pipeline-id $CI_PIPELINE_ID --arch $ARCH --component
      $TEST_COMPONENT
    - aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_PIPELINE
      $FILTER_ARCH $FILTER_INSTANCE_TYPE $FILTER_TEST_COMPONENT --output json --query
      $QUERY_INSTANCE_IDS | tee -a instance.json
    - INSTANCE_ID="$(jq -r '.[0][0]' < instance.json)"
    - echo ${INSTANCE_ID}
    - "if [[ \"${INSTANCE_ID}\" != \"\" ]] && [[ \"${INSTANCE_ID}\" != \"null\" ]];\
      \ then\n  aws ec2 terminate-instances --instance-ids \"${INSTANCE_ID}\"\nfi\n"
    stage: kernel_matrix_testing_cleanup
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      INSTANCE_TYPE: m5d.metal
      TEST_COMPONENT: system-probe
    when: manual
notify_ebpf_complexity_changes
  notify_ebpf_complexity_changes:
    allow_failure: true
    before_script:
    - python3 -m pip install tabulate
    - python3 -m pip install -r tasks/libs/requirements-github.txt
    - GITHUB_KEY_B64=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP key_b64)
      || exit $?; export GITHUB_KEY_B64
    - GITHUB_APP_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP app_id)
      || exit $?; export GITHUB_APP_ID
    - GITHUB_INSTALLATION_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP
      installation_id) || exit $?; export GITHUB_INSTALLATION_ID
    - echo "Using agent GitHub App"
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN)
      || exit $?; export GITLAB_TOKEN
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs:
    - job: kmt_run_sysprobe_tests_x64
      optional: true
      parallel:
        matrix:
        - TAG:
          - amazon_5.4
          - debian_10
          - ubuntu_18.04
          - centos_8
          - opensuse_15.3
          - suse_12.5
          - fedora_38
          TEST_SET: no_usm
    - job: kmt_run_sysprobe_tests_arm64
      optional: true
      parallel:
        matrix:
        - TAG:
          - amazon_5.4
          - debian_10
          - ubuntu_18.04
          - centos_8
          - opensuse_15.3
          - suse_12.5
          - fedora_38
          TEST_SET: no_usm
    rules:
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - 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
    - if: $DEPLOY_AGENT == "false" && $DDR_WORKFLOW_ID == null && $RUN_E2E_TESTS ==
        "off"
      when: never
    - if: $DEPLOY_AGENT == "true" || $DDR_WORKFLOW_ID != null
      when: never
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    - allow_failure: true
      if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/ebpf/**/*
        - pkg/security/**/*
        - pkg/eventmonitor/**/*
        - test/kitchen/site-cookbooks/dd-security-agent-check/**/*
        - test/kitchen/test/integration/security-agent-test/**/*
        - test/kitchen/test/integration/security-agent-stress/**/*
        - .gitlab/functional_test/security_agent.yml
        - .gitlab/kernel_matrix_testing/security_agent.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/security_agent.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    - allow_failure: true
      when: manual
    script:
    - inv -e ebpf.generate-complexity-summary-for-pr
    stage: notify
    tags:
    - arch:amd64
pull_test_dockers_arm64
  pull_test_dockers_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      expire_in: 1 day
      paths:
      - $KMT_DOCKERS
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/docker_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs: []
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - DOCKER_LOGIN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO user)
      || exit $?
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO token | crane auth
      login --username "$DOCKER_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
    - EXIT="${PIPESTATUS[0]}"; if [ $EXIT -ne 0 ]; then echo "Unable to locate credentials
      needs gitlab runner restart"; exit $EXIT; fi
    - mkdir $KMT_DOCKERS
    - inv -e system-probe.save-test-dockers --use-crane --output-dir $KMT_DOCKERS --arch
      $ARCH
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: arm64
      KMT_DOCKERS: $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH
pull_test_dockers_x64
  pull_test_dockers_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      expire_in: 1 day
      paths:
      - $KMT_DOCKERS
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/docker_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs: []
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - DOCKER_LOGIN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO user)
      || exit $?
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO token | crane auth
      login --username "$DOCKER_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
    - EXIT="${PIPESTATUS[0]}"; if [ $EXIT -ne 0 ]; then echo "Unable to locate credentials
      needs gitlab runner restart"; exit $EXIT; fi
    - mkdir $KMT_DOCKERS
    - inv -e system-probe.save-test-dockers --use-crane --output-dir $KMT_DOCKERS --arch
      $ARCH
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      KMT_DOCKERS: $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH
upload_dependencies_sysprobe_arm64
  upload_dependencies_sysprobe_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    before_script:
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - pull_test_dockers_arm64
    - go_deps
    - go_tools_deps
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - "if [ -d $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH ]; then\n  tar czvf $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH.tar.gz\
      \ -C $DD_AGENT_TESTING_DIR kmt-dockers-$ARCH\n  scp $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH.tar.gz\
      \ metal_instance:/opt/kernel-version-testing\nfi\n"
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: arm64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      INSTANCE_TYPE: m6gd.metal
      TEST_COMPONENT: system-probe
upload_dependencies_sysprobe_x64
  upload_dependencies_sysprobe_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    before_script:
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - pull_test_dockers_x64
    - go_deps
    - go_tools_deps
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - "if [ -d $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH ]; then\n  tar czvf $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH.tar.gz\
      \ -C $DD_AGENT_TESTING_DIR kmt-dockers-$ARCH\n  scp $DD_AGENT_TESTING_DIR/kmt-dockers-$ARCH.tar.gz\
      \ metal_instance:/opt/kernel-version-testing\nfi\n"
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      INSTANCE_TYPE: m5d.metal
      TEST_COMPONENT: system-probe
upload_minimized_btfs_sysprobe_arm64
  upload_minimized_btfs_sysprobe_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - generate_minimized_btfs_arm64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - mkdir -p $DEPENDENCIES
    - pushd $DEPENDENCIES
    - mkdir -p $BTF_DIR
    - cp $CI_PROJECT_DIR/minimized-btfs.tar.xz $BTF_DIR/minimized-btfs.tar.xz
    - popd
    - ls -la $DEPENDENCIES
    - pushd $CI_PROJECT_DIR/kmt-deps/ci/$ARCH
    - tar czvf $ARCHIVE_NAME btfs
    - popd
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/$ARCHIVE_NAME metal_instance:/opt/kernel-version-testing/
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: arm64
      ARCHIVE_NAME: btfs-arm64.tar.gz
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      BTF_DIR: opt/kmt-ramfs/system-probe-tests/pkg/ebpf/bytecode/build/${ARCH}/co-re/btf
      DEPENDENCIES: $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/btfs
      INSTANCE_TYPE: m6gd.metal
      TEST_COMPONENT: system-probe
upload_minimized_btfs_sysprobe_x64
  upload_minimized_btfs_sysprobe_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - generate_minimized_btfs_x64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - mkdir -p $DEPENDENCIES
    - pushd $DEPENDENCIES
    - mkdir -p $BTF_DIR
    - cp $CI_PROJECT_DIR/minimized-btfs.tar.xz $BTF_DIR/minimized-btfs.tar.xz
    - popd
    - ls -la $DEPENDENCIES
    - pushd $CI_PROJECT_DIR/kmt-deps/ci/$ARCH
    - tar czvf $ARCHIVE_NAME btfs
    - popd
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/$ARCHIVE_NAME metal_instance:/opt/kernel-version-testing/
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      ARCHIVE_NAME: btfs-x86_64.tar.gz
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      BTF_DIR: opt/kmt-ramfs/system-probe-tests/pkg/ebpf/bytecode/build/${ARCH}/co-re/btf
      DEPENDENCIES: $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/btfs
      INSTANCE_TYPE: m5d.metal
      TEST_COMPONENT: system-probe
upload_sysprobe_tests_arm64
  upload_sysprobe_tests_arm64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      paths:
      - $CI_PROJECT_DIR/connector-${ARCH}
      when: always
    before_script:
    - mkdir -p $GOPATH/pkg/mod/cache && tar xJf modcache.tar.xz -C $GOPATH/pkg/mod/cache
    - rm -f modcache.tar.xz
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_arm64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - go_deps
    - prepare_sysprobe_ebpf_functional_tests_arm64
    - tests_ebpf_arm64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - pushd $CI_PROJECT_DIR/kmt-deps/ci/$ARCH
    - tar czvf $TEST_ARCHIVE_NAME opt
    - popd
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/$TEST_ARCHIVE_NAME metal_instance:/opt/kernel-version-testing/
    - pushd $CI_PROJECT_DIR/test/new-e2e
    - go build -o $CI_PROJECT_DIR/connector-${ARCH} $CI_PROJECT_DIR/test/new-e2e/system-probe/connector/main.go
    - popd
    - scp $CI_PROJECT_DIR/connector-${ARCH} metal_instance:/home/ubuntu/connector
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:arm64
    variables:
      ARCH: arm64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      INSTANCE_TYPE: m6gd.metal
      TEST_ARCHIVE_NAME: tests-$ARCH.tar.gz
      TEST_COMPONENT: system-probe
upload_sysprobe_tests_x64
  upload_sysprobe_tests_x64:
    after_script:
    - DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $API_KEY_ORG2) || exit $?;
      export DD_API_KEY
    - inv -e kmt.tag-ci-job
    artifacts:
      paths:
      - $CI_PROJECT_DIR/connector-${ARCH}
      when: always
    before_script:
    - mkdir -p $GOPATH/pkg/mod/cache && tar xJf modcache.tar.xz -C $GOPATH/pkg/mod/cache
    - rm -f modcache.tar.xz
    - mkdir -p ~/.aws
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_QA_PROFILE >> ~/.aws/config ||
      exit $?
    - export AWS_PROFILE=agent-qa-ci
    - touch $AWS_EC2_SSH_KEY_FILE && chmod 600 $AWS_EC2_SSH_KEY_FILE
    - $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $SSH_KEY > $AWS_EC2_SSH_KEY_FILE || exit
      $?
    - echo "" >> $AWS_EC2_SSH_KEY_FILE
    - chmod 600 $AWS_EC2_SSH_KEY_FILE
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/system-probe_x64$DATADOG_AGENT_SYSPROBE_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_SYSPROBE_BUILDIMAGES
    needs:
    - go_deps
    - prepare_sysprobe_ebpf_functional_tests_x64
    - tests_ebpf_x64
    rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - if: $RUN_KMT_TESTS == 'on'
    - changes:
        compare_to: main
        paths:
        - pkg/collector/corechecks/ebpf/**/*
        - pkg/collector/corechecks/servicediscovery/module/*
        - pkg/ebpf/**/*
        - pkg/network/**/*
        - pkg/process/monitor/*
        - pkg/util/kernel/**/*
+       - pkg/dynamicinstrumentation/**/*
        - .gitlab/kernel_matrix_testing/system_probe.yml
        - .gitlab/kernel_matrix_testing/common.yml
        - .gitlab/source_test/ebpf.yml
        - test/new-e2e/system-probe/**/*
        - test/new-e2e/scenarios/system-probe/**/*
        - test/new-e2e/pkg/runner/**/*
        - test/new-e2e/pkg/utils/**/*
        - test/new-e2e/go.mod
        - tasks/system_probe.py
        - tasks/kmt.py
        - tasks/kernel_matrix_testing/*
    script:
    - pushd $CI_PROJECT_DIR/kmt-deps/ci/$ARCH
    - tar czvf $TEST_ARCHIVE_NAME opt
    - popd
    - FILTER_TEAM="Name=tag:team,Values=ebpf-platform"
    - FILTER_MANAGED="Name=tag:managed-by,Values=pulumi"
    - FILTER_STATE="Name=instance-state-name,Values=running"
    - FILTER_PIPELINE="Name=tag:pipeline-id,Values=${CI_PIPELINE_ID}"
    - FILTER_ARCH="Name=tag:arch,Values=${ARCH}"
    - FILTER_INSTANCE_TYPE="Name=tag:instance-type,Values=${INSTANCE_TYPE}"
    - FILTER_TEST_COMPONENT="Name=tag:test-component,Values=${TEST_COMPONENT}"
    - QUERY_INSTANCE_IDS='Reservations[*].Instances[*].InstanceId'
    - QUERY_PRIVATE_IPS='Reservations[*].Instances[*].PrivateIpAddress'
    - "COUNTER=0\nwhile [[ $(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED\
      \ $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE\
      \ --output text --query $QUERY_INSTANCE_IDS  | wc -l ) != \"1\" && $COUNTER -le\
      \ 80 ]]; do COUNTER=$[$COUNTER +1]; echo \"[${COUNTER}] Waiting for instance\"\
      ; sleep 30; done\n# check that instance is ready, or fail\nif [ $(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS | wc -l) -ne\
      \ \"1\" ]; then\n    echo \"Instance NOT found\"\n    touch ${CI_PROJECT_DIR}/instance_not_found\n\
      \    \"false\"\nfi\necho \"Instance found\"\nINSTANCE_ID=$(aws ec2 describe-instances\
      \ --filters $FILTER_TEAM $FILTER_MANAGED $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT\
      \ $FILTER_INSTANCE_TYPE --output text --query $QUERY_INSTANCE_IDS)\naws ec2 wait\
      \ instance-status-ok --instance-ids $INSTANCE_ID\nsleep 10\n"
    - INSTANCE_IP=$(aws ec2 describe-instances --filters $FILTER_TEAM $FILTER_MANAGED
      $FILTER_STATE $FILTER_PIPELINE $FILTER_TEST_COMPONENT $FILTER_INSTANCE_TYPE --output
      text --query $QUERY_PRIVATE_IPS)
    - echo "$ARCH-instance-ip" $INSTANCE_IP
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo -e "Host metal_instance\nHostname $INSTANCE_IP\nUser ubuntu\nStrictHostKeyChecking
      no\nIdentityFile $AWS_EC2_SSH_KEY_FILE\n" | tee -a ~/.ssh/config
    - chmod 600 ~/.ssh/config
    - scp $CI_PROJECT_DIR/kmt-deps/ci/$ARCH/$TEST_ARCHIVE_NAME metal_instance:/opt/kernel-version-testing/
    - pushd $CI_PROJECT_DIR/test/new-e2e
    - go build -o $CI_PROJECT_DIR/connector-${ARCH} $CI_PROJECT_DIR/test/new-e2e/system-probe/connector/main.go
    - popd
    - scp $CI_PROJECT_DIR/connector-${ARCH} metal_instance:/home/ubuntu/connector
    stage: kernel_matrix_testing_prepare
    tags:
    - arch:amd64
    variables:
      ARCH: x86_64
      AWS_EC2_SSH_KEY_FILE: $CI_PROJECT_DIR/ssh_key
      INSTANCE_TYPE: m5d.metal
      TEST_ARCHIVE_NAME: tests-$ARCH.tar.gz
      TEST_COMPONENT: system-probe

Changes Summary

Removed Modified Added Renamed
0 25 0 0

ℹ️ Diff available in the job log.

@pr-commenter
Copy link

pr-commenter bot commented Sep 20, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=45884912 --os-family=ubuntu

Note: This applies to commit 63e1573

@grantseltzer
Copy link
Member Author

Are the tests that I added running in KMT? Some of the tests are designed to fail, but I don't see anything

@grantseltzer
Copy link
Member Author

My tests are being triggered to run now, but it can't find the go binary for compiling the testing sample service. How does this work for USM or other places where Go is invoked?

@grantseltzer grantseltzer requested a review from a team as a code owner September 24, 2024 18:08
tasks/kmt.py Outdated Show resolved Hide resolved
Copy link

cit-pr-commenter bot commented Sep 25, 2024

Go Package Import Differences

Baseline: 70ded07
Comparison: 63e1573

binaryosarchchange
system-probelinuxamd64
+0, -11
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/codegen
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/diagnostics
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/diconfig
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/ditypes
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/ebpf
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/eventparser
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/proctracker
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/ratelimiter
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/uploader
-github.com/DataDog/datadog-agent/pkg/dynamicinstrumentation/util
system-probelinuxarm64
+3, -0
+github.com/kr/pretty
+github.com/kr/text
+github.com/rogpeppe/go-internal/fmtsort

@grantseltzer
Copy link
Member Author

/trigger-ci --variable RUN_ALL_BUILDS=true --variable RUN_KITCHEN_TESTS=true --variable RUN_E2E_TESTS=on --variable RUN_UNIT_TESTS=on --variable RUN_KMT_TESTS=on

@dd-devflow
Copy link

dd-devflow bot commented Sep 26, 2024

🚨 Devflow

Post "https://gitlab.ddbuild.io/api/v4/projects/DataDog%2Fdatadog-agent/pipeline": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

Details
child workflow execution error (type: devflow.Devflow_TriggerCiFromPr, workflowID: ddde2c69-57d6-4c0f-b883-3e61b9c5bae4_26, runID: c664b223-850c-42a8-9d02-e532efc218c9, initiatedEventID: 26, startedEventID: 27): child workflow execution error (type: devflow.Devflow_TriggerCi, workflowID: c664b223-850c-42a8-9d02-e532efc218c9_14, runID: f48ecd15-c827-4744-8995-44e974e96337, initiatedEventID: 14, startedEventID: 15): activity error (type: gitlab.GitlabService_CreatePipeline, scheduledEventID: 26, startedEventID: 27, identity: ): activity ScheduleToClose timeout (type: ScheduleToClose): Post "https://gitlab.ddbuild.io/api/v4/projects/DataDog%2Fdatadog-agent/pipeline": net/http: request canceled (Client.Timeout exceeded while awaiting headers) (type: Error, retryable: true): net/http: request canceled (Client.Timeout exceeded while awaiting headers) (type: timeoutError, retryable: true)

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

@grantseltzer
Copy link
Member Author

/trigger-ci --variable RUN_ALL_BUILDS=true --variable RUN_KITCHEN_TESTS=true --variable RUN_E2E_TESTS=on --variable RUN_UNIT_TESTS=on --variable RUN_KMT_TESTS=on

@dd-devflow
Copy link

dd-devflow bot commented Sep 26, 2024

🚂 Gitlab pipeline started

Started pipeline #45217774

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Sep 26, 2024

[Fast Unit Tests Report]

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

Jobs:
  • 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

@grantseltzer
Copy link
Member Author

I have one failure due to rlimit memlock. Is it safe to remove the memory lock for this case?

@pr-commenter
Copy link

pr-commenter bot commented Sep 27, 2024

Regression Detector

Regression Detector Results

Run ID: f9b4ece5-48ba-43b9-b66e-be90fcde77d5 Metrics dashboard Target profiles

Baseline: 70ded07
Comparison: 63e1573

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
otel_to_otel_logs ingress throughput +1.77 [+0.96, +2.59] 1 Logs
pycheck_lots_of_tags % cpu utilization +0.77 [-1.77, +3.30] 1 Logs
tcp_syslog_to_blackhole ingress throughput +0.20 [+0.16, +0.24] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.01 [-0.11, +0.08] 1 Logs
idle memory utilization -0.35 [-0.39, -0.30] 1 Logs
idle_all_features memory utilization -0.37 [-0.46, -0.27] 1 Logs
basic_py_check % cpu utilization -1.03 [-3.72, +1.67] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -1.09 [-1.82, -0.36] 1 Logs
file_tree memory utilization -1.39 [-1.51, -1.27] 1 Logs

Bounds Checks

perf experiment bounds_check_name replicates_passed
idle memory_usage 10/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".

@gjulianm gjulianm removed their request for review September 30, 2024 09:11
)

func TestGoDI(t *testing.T) {
if err := rlimit.RemoveMemlock(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test will fail without this, I'd suggest require.NoError(t, rlimit.RemoveMemlock())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are calling it twice now? You just need the single line require.NoError(t, rlimit.RemoveMemlock())


// Read the configuration via the config manager
_, err := cm.ConfigReader.Read(buf.Bytes())
time.Sleep(time.Second * 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why this sleep is here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we call ConfigReader.Read() this kicks off the process of DI reading the configuration, then reading the DWARF information of the binary, generating the bpf code, compiling, and attaching. Then the events are read from the ringbuffer async. So this gives it time to do all that. 5 seconds is likely overly generous, but we do need a sleep.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary for this PR, but I'd suggest trying to find something to wait on instead. Perhaps something in eventOutputWriter?

Copy link
Member Author

@grantseltzer grantseltzer Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I started playing with this and realized two things:

  1. We don't need to sleep for waiting for DI to start up, the DI entry point function returns when things are set up.

  2. There is, however, a sort of race condition when a new config is read where the expected result is updated but there could still be events in the ringbuffer from the previously instrumented function.

So, the diagnostics system seems like the perfect place for creating statuses that can be waited on instead of sleeping. When a new probe gets updated, and when a previous one gets uninstalled, we can change what the expected result is. We can also use it for confirming that events are received.

That said, I think let's do that in a subsequent PR. I changed the sleep logic to fix it for now.

grantseltzer and others added 12 commits October 3, 2024 20:36
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grant.seltzerrichman <grant.seltzerrichman@datadoghq.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
@grantseltzer grantseltzer force-pushed the grantseltzer/DEBUG-2830/testing-for-go-di branch from e970a78 to 099089c Compare October 4, 2024 01:36
Copy link
Collaborator

@cimi cimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the dynamic instrumentation changes - the new config managers are only used in tests and when running in offline mode.

I'm not familiar with the KMT test setup but I've seen that the new test pass in KMT runs.

}

opts := &dynamicinstrumentation.DIOptions{
RateLimitPerProbePerSecond: 0.0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this zero?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to rate limit for testing, this means we'll collect events whenever they're produced and we can see if they're as expected.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rate limit shouldn't affect the tests though, they should still pass.

I guess resources are not a problem and we test one probe at a time so it's fine to leave rate limiting turned off but we might want to use the same values in tests as in the expected user configuration.

Signed-off-by: grantseltzer <grantseltzer@gmail.com>
@grantseltzer grantseltzer removed the request for review from a team October 4, 2024 19:40
@grantseltzer grantseltzer force-pushed the grantseltzer/DEBUG-2830/testing-for-go-di branch from b96b2b7 to 60bbf38 Compare October 4, 2024 19:48
go func(updateChan <-chan []byte) {
configUpdateLoop:
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit strange to handle the signal this deep. Also, a signal isn't the only way you want graceful termination. Within a test, you will want to stop everything gracefully, but there is no signal at test end.

A couple ways you could solve this:

  • return a function that closes the channel, which will exit the goroutine. Call the function in the parent Close function.
  • create a wrapping type here that provides a Stop/Close function, and call that in the parent.

@@ -33,10 +32,11 @@ func (goDI *GoDI) startRingbufferConsumer() (func(), error) {
closeFunc := func() {
closed = true
r.Close()
r.Flush()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really do anything since you already closed it.

Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
@grantseltzer
Copy link
Member Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Oct 4, 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!

@grantseltzer grantseltzer added the qa/done Skip QA week as QA was done before merge and regressions are covered by tests label Oct 4, 2024
@dd-devflow
Copy link

dd-devflow bot commented Oct 4, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 22m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit 874a19c into main Oct 4, 2024
299 of 323 checks passed
@dd-mergequeue dd-mergequeue bot deleted the grantseltzer/DEBUG-2830/testing-for-go-di branch October 4, 2024 22:02
@github-actions github-actions bot added this to the 7.59.0 milestone Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog component/system-probe qa/done Skip QA week as QA was done before merge and regressions are covered by tests team/dynamic-instrumentation Dynamic Instrumentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants