← Back to Pull requests

test(e2e): swap DatadogAgents without Pulumi in TestGenericK8s #3846

Closed
unknown closed this pull request without merging on Nov 26, 2026 10:10 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 09:10 UTC
Author

What does this PR do?

Speeds up TestAWSKindSuite/TestGenericK8s, the main e2e CI job (9 Kubernetes versions):

  • No more pulumi up between subtests. Each subtest called UpdateEnv twice: once to remove the previous DatadogAgent, once to apply the new one. Each call is a full pulumi up over the whole stack (VM, fakeintake, kind, operator). Subtests now apply their DatadogAgent and workloads with the Kubernetes API (test/e2e/tests/k8s_suite/scenario_test.go). Pulumi still provisions the infrastructure and the operator once, in SetupSuite.

  • - Previous DatadogAgent: it is deleted first, and the swap waits until it is gone and its pods have terminated. Its finalizer deletes the DatadogAgentInternals, which are never deleted directly: the operator would re-create them. This keeps a new agent from starting while the previous agent pods still hold resources such as host ports.
    - DatadogAgent content: the DatadogAgent gets what the e2e-framework's DatadogAgent component added (credentials secret, cluster name, fakeintake env vars, image pull secret), merged with the same mergo calls.
    - Workloads: the previous scenario's workloads that the next one doesn't list are deleted, as Pulumi did.
  • Only the k8s_suite package is built by make e2e-tests when E2E_RUN_REGEX is empty. It used to build every suite only to report "no tests to run".

  • Every suite's cleanup before stack destroy deletes only DatadogAgents (utils.DeleteAllDatadogAgents), in the untaint, componenthealth and GKE Autopilot suites too. DeleteAllDatadogResources, which also deleted DatadogAgentInternals directly, is removed.

  • Pulumi progress is streamed in the e2e job (E2E_PULUMI_VERBOSE_PROGRESS_STREAMS). The e2e-framework only prints Pulumi errors by default, so stack up and destroy were silent for minutes.
  • Motivation

    The e2e jobs (9 Kubernetes versions) are on the critical path of every pipeline. Almost all of TestGenericK8s went into the per-subtest pulumi up runs, not into the assertions.

    Results

    Before is the main pipeline at 9450780ff; after is this PR at 55eb27b0b. Every e2e job of the matrix passed, taking 21m32–24m40 instead of 47–56 min.

    | Step | 1.19 before | 1.19 after | 1.30 before | 1.30 after | 1.36 before | 1.36 after |
    |---|---|---|---|---|---|---|
    | Job total | 47m32 | 24m17 | 52m07 | 21m32 | 48m16 | 22m52 |
    | Pre-script (runner pod, artifacts, cache untar) ¹ | ~2m | 4m02 | ~3.5m | 1m54 | 1m54 | 3m40 |
    | Building the test binaries | 76s | 36s | 66s | 35s | 72s | 38s |
    | Initial stack up | 5m20 | 5m23 | 10m35 ² | 5m28 | 4m53 | 4m43 |
    | TestGenericK8s | 34m21 | 10m26 | 32m27 | 9m29 | 35m38 | 9m47 |
    | ↳ DatadogAgent swaps ³ | 30.1m | 1.5m | 27.8m | 0.75m | 31.2m | 1.2m |
    | ↳ assertions ⁴ | 4.0m | 8.8m | 4.4m | 8.6m | 4.4m | 8.5m |
    | Stack destroy | 4m33 | 3m47 | 4m29 | 4m03 | 4m35 | 4m01 |

    1. Runner scheduling (pod Pending), unrelated to this change.
    2. Not reproduced. The log then was silent; with progress streaming, 1.30 now takes as long as the other versions.
    3. Before: 20 pulumi up runs (70–130s each). After: deleting the previous DatadogAgent and waiting for its pods takes 5–15s, and applying the new manifest takes under 1s.
    4. Agent startup used to happen during the second pulumi up of each subtest. It now happens inside the assertions. APM (~150s, waiting for tracegen and the agent) and KSM on the cluster checks runner (~90s) are the longest.

    What the new Pulumi logs show

    These are the remaining ~5 min of stack up and ~4 min of destroy, from the 1.19, 1.30 and 1.36 jobs.

    Stack up, which is fully serialized:
    1. The ECS fakeintake service takes 125–136s.
    2. The EC2 instance only starts after the fakeintake is healthy, because the framework makes the VM depend on it. It takes 12–13s.
    3. Cloud-init on the VM takes 28–42s, and apt updates and installs take ~20s.
    4. kind create cluster takes 44–71s, depending on the Kubernetes version.
    5. Kubernetes resources take ~35s: the operator Helm release (7–28s), our kustomize CRDs and RBAC, and the VPA CRD.

    Stack destroy:
    1. Kubernetes resources are deleted one by one through the API for ~75–80s, even though the VM is terminated right after. That covers the CRDs and RBAC from our kustomize, plus the Helm release and VPA CRD. The last two are marked DeletedWith(kubeProvider) in the framework, but they are still deleted, so DeletedWith on the provider doesn't skip them.
    2. EC2 termination takes 30–40s.
    3. The ECS service is deleted only after the instance, for 106–116s.

    The pre-destroy DatadogAgent cleanup takes 5s.

    Follow-ups

  • Faster provisioning and teardown, in datadog-agent's e2e-framework (separate PR):

  • - Run the fakeintake on the kind VM instead of ECS, or at least stop making the VM wait for it: ~2 min on stack up and ~2 min on destroy.
    - Skip Kubernetes resource deletion when the VM goes away, with DeletedWith on the VM or kind cluster rather than on the provider, including for workloads we pass in: ~75s.
    - Optionally skip the VPA CRD and CSI driver.
    - Together, these could bring stack up from ~5 min to ~3 min and destroy from ~4 min to under 1 min.
  • Shorter assertion poll intervals here (15s/30s ticks): they could save ~5–10s per subtest.
  • Additional Notes

  • Differences from the previous Pulumi path:

  • - The Datadog CSI driver is no longer deployed with the DatadogAgent; no manifest uses CSI.
    - The DatadogAgent clusterName is the kind cluster name instead of the Pulumi stack name; no assertion uses it.
    - Workloads are no longer awaited by Pulumi; the subtests' Eventually checks cover them.
  • Unit test: TestBuildDatadogAgent checks the DatadogAgent built from each manifest without infrastructure: cd test/e2e && GOWORK=off go test -tags e2e ./tests/k8s_suite/ -run TestBuildDatadogAgent. CI doesn't run it.
  • Minimum Agent Versions

    N/A (tests only)

    Agent: N/A
    Cluster Agent: N/A

    Describe your test plan

  • Check that the e2e jobs pass on all Kubernetes versions. Watch 1.19 in particular, since it is the most sensitive to DatadogAgent swaps.

  • Compare the TestGenericK8s and job durations with the table above. The per-subtest Previous DatadogAgent removed in and Scenario ... applied in logs show the swap cost.

  • Check that the stack up and destroy logs now show Pulumi progress.

  • e2e_untaint and e2e_componenthealth run automatically on this PR, since it touches their suites and test/e2e/provisioners/kind.go; they check the new cleanup. e2e_gke_autopilot is manual.
  • Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies

  • PR has a milestone or the qa/skip-qa label

  • All commits are signed (see: [signing commits][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: gabedos Review duration: 1500m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #3846"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%