Repository navigation
Expose configuration for event collection mode - #3642
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
…lection Adds a collectionMode field (poll|watch) to the event collection feature, mapped to the kubernetes_apiserver check's event_collection_mode option. "watch" streams events through a single persistent reflector-backed watch instead of re-opening a watch on every check run. - The check ConfigMap is only mounted when something non-default is requested (unbundled events or watch), so existing users keep the Cluster Agent image's default config and unbundled-events users get a byte-identical ConfigMap. - event_collection_mode and collected_event_types are omitted when empty; the Cluster Agent rejects an explicit empty event_collection_mode. - watch is gated on Cluster Agent >= 7.81.1 (backported in DataDog/datadog-agent#53329); older versions log and keep the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 665cfdaad2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| case collectionModeWatch: | ||
| clusterAgentVersion := images.ClusterAgentLatestVersion | ||
| if clusterAgent, ok := ddaSpec.Override[v2alpha1.ClusterAgentComponentName]; ok && clusterAgent != nil && clusterAgent.Image != nil { | ||
| clusterAgentVersion = common.GetAgentVersionFromImage(*clusterAgent.Image) |
There was a problem hiding this comment.
Derive the gate from the effective Cluster Agent image
When image.name is a full tagged reference and image.tag is also present, the image resolver ignores image.tag, but GetAgentVersionFromImage gives it priority. For example, name: cluster-agent:7.81.1 with a stale tag: 7.81.0 deploys 7.81.1 while this gate silently disables the requested watch mode; the inverse can enable it on an unsupported image. Resolve the version using the same precedence as the actual image assembly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🟢 Approval recommended
Configuration wiring, version gating, generated schemas, and test coverage are consistent, with no blocking issues identified.
No open issues 🎉
2 files not reviewed
api/datadoghq/v2alpha1/zz_generated.deepcopy.go: Generated fileapi/datadoghq/v2alpha1/zz_generated.openapi.go: Generated file
What changed in this PR
Exposes Kubernetes event collection mode through the Datadog Operator, enabling persistent watch collection on supported Cluster Agents while preserving default behavior.
Changes:
- Adds optional
collectionMode: poll|watchconfiguration with schema validation. - Generates watch configuration only for Cluster Agent 7.81.1+.
- Updates generated APIs, documentation, and configuration tests.
| File | Description |
|---|---|
| pkg/testutils/builder.go | Adds collection-mode test helper. |
| internal/controller/datadogagent/feature/eventcollection/feature.go | Wires collection mode with version gating. |
| internal/controller/datadogagent/feature/eventcollection/feature_test.go | Covers modes, version boundaries, and unbundling. |
| internal/controller/datadogagent/feature/eventcollection/configmap.go | Emits optional collection-mode configuration. |
| docs/configuration.v2alpha1.md | Documents the new option. |
| docs/configuration_public.md | Updates public configuration reference. |
| config/crd/bases/v1/datadoghq.com_datadogagents.yaml | Adds Agent schema validation. |
| config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json | Updates Agent JSON schema. |
| config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml | Adds profile schema validation. |
| config/crd/bases/v1/datadoghq.com_datadogagentprofiles_v1alpha1.json | Updates profile JSON schema. |
| config/crd/bases/v1/datadoghq.com_datadogagentinternals.yaml | Adds internal resource schema validation. |
| config/crd/bases/v1/datadoghq.com_datadogagentinternals_v1alpha1.json | Updates internal resource JSON schema. |
| api/datadoghq/v2alpha1/zz_generated.openapi.go | Exposes the field in OpenAPI. |
| api/datadoghq/v2alpha1/zz_generated.deepcopy.go | Copies the optional field. |
| api/datadoghq/v2alpha1/datadogagent_types.go | Defines and documents the API field. |
Review effort: Balanced
What does this PR do?
Adds a collectionMode field (poll|watch) to the event collection feature, mapped to the kubernetes_apiserver check's event_collection_mode option. "watch" streams events through a single persistent reflector-backed watch instead of re-opening a watch on every check run.
Motivation
Expose a new agent configuration.
Minimum Agent Versions
Describe your test plan
Tested on minikube (Kubernetes v1.37.0, containerd 2.3.4) with an operator image built from this branch. Each scenario was checked by running
agent configcheckin the Cluster Agent, where thekubernetes_apiservercheck runs.Default (no
collectionMode)Supporting configuration
Proof
Outcome:
PASSexisting behavior is unchanged: no ConfigMap, and the check runs from the image default.collectionMode: pollSupporting configuration
Proof
Outcome:
PASSan explicitpollis treated like the default: no ConfigMap, and the Cluster Agent isn't restarted.collectionMode: watchSupporting configuration
Proof
Outcome:
PASSevent_collection_mode: watchreaches the check and the Cluster Agent logs no config errors.unbundleEventsonly (nocollectionMode)Supporting configuration
Proof
Outcome:
PASSthe unbundled-events ConfigMap is the same as before this change, with noevent_collection_modekey. An empty value would make the Cluster Agent reject the config.collectionMode: watchwithunbundleEventsSupporting configuration
Proof
Outcome:
PASSwatch mode and unbundled events are both in the same check config.collectionMode: watch, Cluster Agent < 7.81.1Supporting configuration
Proof
Outcome:
PASSwatch is not enabled on an unsupported Cluster Agent, and the operator's logs include the configuration error.collectionMode: watch, Cluster Agent = 7.81.1Supporting configuration
Proof
Outcome:
PASSthe minimum-version boundary is inclusive, and the 7.81.1 check runs[OK]with watch mode.Invalid
collectionModeSupporting configuration
Proof
Outcome:
PASSCRD enum validation rejects invalid values before they reach the operator.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel