[Backport v1.33] test(e2e): swap DatadogAgents without Pulumi in TestGenericK8s #3855
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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 #3855"
general
weight: 0.35
tbavelier
Backport a33025fce0feb4bce0de80ef707b46172bd45aa1 from #3846.
___
What does this PR do?
Speeds up
TestAWSKindSuite/TestGenericK8s, the maine2eCI job (9 Kubernetes versions):pulumi upbetween subtests. Each subtest calledUpdateEnvtwice: once to remove the previous DatadogAgent, once to apply the new one. Each call is a fullpulumi upover 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, inSetupSuite.- 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
mergocalls.- Workloads: the previous scenario's workloads that the next one doesn't list are deleted, as Pulumi did.
k8s_suitepackage is built bymake e2e-testswhenE2E_RUN_REGEXis empty. It used to build every suite only to report "no tests to run".utils.DeleteAllDatadogAgents), in the untaint, componenthealth and GKE Autopilot suites too.DeleteAllDatadogResources, which also deleted DatadogAgentInternals directly, is removed.e2ejob (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
e2ejobs (9 Kubernetes versions) are on the critical path of every pipeline. Almost all ofTestGenericK8swent into the per-subtestpulumi upruns, not into the assertions.Results
Before is the main pipeline at 9450780ff; after is this PR at 55eb27b0b. Every
e2ejob 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 upruns (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 upof 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 clustertakes 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, soDeletedWithon 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
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
DeletedWithon 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.
Additional Notes
- The Datadog CSI driver is no longer deployed with the DatadogAgent; no manifest uses CSI.
- The DatadogAgent
clusterNameis the kind cluster name instead of the Pulumi stack name; no assertion uses it.- Workloads are no longer awaited by Pulumi; the subtests'
Eventuallychecks cover them.TestBuildDatadogAgentchecks 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
e2ejobs pass on all Kubernetes versions. Watch 1.19 in particular, since it is the most sensitive to DatadogAgent swaps.TestGenericK8sand job durations with the table above. The per-subtestPrevious DatadogAgent removed inandScenario ... applied inlogs show the swap cost.e2e_untaintande2e_componenthealthrun automatically on this PR, since it touches their suites andtest/e2e/provisioners/kind.go; they check the new cleanup.e2e_gke_autopilotis manual.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
🤖 Generated with Claude Code