[CLOUDPREM-889] Add BYOC and Worker defaults and runtime validation #3554
<!-- codex-pull-request-review-summary -->
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-10-06T08:41:26.154482Z">2026-10-06T08:41:26.154482Z</relative-time> | 98e9c6b | New commits |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your 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.
</details>
<sub><sub>!P2 Badge</sub></sub> Reject empty override digests even when a release exists
When a valid release is combined with an override such as imageOverrides.byoc.digest: "", the CRD accepts the empty digest and this check is skipped because requireComplete is false. Image resolution then treats the non-nil digest as an explicit version override, clearing the inherited release tag and producing an image reference ending in :, so the managed workload cannot start. Validate a present digest as non-empty regardless of whether the release supplies other image fields.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Validate explicit autoscaling bounds before defaulting
For either a BYOC stateful component or standalone Worker with both bounds specified, this shared validator accepts configurations such as minReplicas: 5 and maxReplicas: 2 (and the generated CRDs impose no bounds). Both defaulting implementations preserve those values, so the eventual HorizontalPodAutoscaler is rejected instead of the parent resource receiving the intended configuration error. Validate that the explicit maximum is positive and not below the minimum here.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e59e5749b1
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Fixed in f83ab35d: image digests must now match ^sha256:[a-f0-9]{64}$ in the CRD schema, so an empty override digest is rejected at admission whether or not a release is set. Release repository and tag now also require at least one character.
Fixed in 8aac3c35: ValidateStatefulComponent now requires minReplicas/maxReplicas >= 1 and minReplicas <= maxReplicas. The validators are meant to run on the defaulted spec, so a single explicit bound is also checked against the default of the other (e.g. maxReplicas: 1 vs. the BYOC default minReplicas: 2). The reconcilers that apply defaults before validating come in a follow-up PR.
<sub><sub>!P2 Badge</sub></sub> Require memory limits for worker components
When a BYOC pipeline or standalone Worker supplies a non-nil resources object without limits.memory, this generic validator accepts it. Both worker paths use ValidateStatefulComponent—including the BYOC pipeline call in datadogbyoccluster/validation.go—whereas only indexer/searcher receive the memory-limit check, despite both worker API types requiring that limit for buffer sizing; add equivalent worker-specific validation before reconciliation proceeds.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Default explicitly empty PVC access modes
When a pipeline PVC template contains accessModes: [], decoding produces a non-nil but empty slice, so this condition skips the ReadWriteOnce default. The generated PersistentVolumeClaim then has no access modes and is rejected by the Kubernetes API; use an empty-length check here and in the identical indexer path so both omitted and explicitly empty lists receive the default.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Validate PodDisruptionBudget value syntax
When either budget value is an invalid percentage such as "nope" or a negative integer, the CRD admits it because these fields are unconstrained IntOrString values, and this validator accepts it whenever only one field is present. The resulting managed PodDisruptionBudget is rejected by the Kubernetes API, leaving the parent resource unable to reconcile; validate each configured value as a non-negative integer or valid percentage in addition to checking mutual exclusion.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Reject empty release versions
When release.tag or release.digest is present but empty, this pointer-only XOR check accepts the release. In the reviewed tree those release fields still have no minimum-length schema constraint, and resolveRelease dereferences the selected version to an empty string before attempting OCI resolution, so reconciliation fails later instead of reporting invalid configuration; require the selected value to be non-empty.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8aac3c3532
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Not important
Not important
Not important
<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3554'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok-light.svg" alt="Code Coverage" align="center" /></picture></a>
🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3554'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 100.00%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 53.02% <span title="Change in overall coverage compared to the base branch">(+0.50%)</span><br>
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 98e9c6b | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
The Operator does not use the Worker memory limit for buffer sizing; neither the Worker nor the BYOC pipeline reads it. Only the Indexer and Searcher size their Quickwit configuration from it, so the check stays scoped to them. The API doc note was stale and was removed in eb7da580.
<sub><sub>!P2 Badge</sub></sub> Preserve a CPU request for default CPU autoscaling
When autoscaling is enabled with omitted metrics but the user supplies any non-nil partial resources object without requests.cpu, this branch preserves that object while applyAutoscalingDefaults injects a CPU-utilization metric. Kubernetes cannot calculate utilization for a pod whose relevant container has no CPU request, so the HPA remains unable to scale; the standalone Worker defaulting path has the same interaction. Merge the default CPU request when selecting this metric, or reject/default this combination.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Default fields inside standalone Worker PVC templates
When a standalone Worker selects storage.volumeClaimTemplate: {}, this condition skips storage defaulting entirely, and no later Worker code supplies an access mode or storage request. ValidateStatefulComponent accepts the template because exactly one storage type is present, but the resulting PVC is rejected for lacking its required access modes and requested capacity; apply the same ReadWriteOnce/capacity defaults used for BYOC pipeline claims, or validate that an opted-in Worker claim is complete.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb7da580e2
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
should this be set if autoscaling is also configured?
Approved these changes.
nit: I don't think we should by talking about Quickwit here.
nit: I don't think we should by talking about Quickwit here.
nit: it would be good to have all the constant values defined and grouped at the beginning of the file.
It makes eyeballing values easier compared to look into the code.
A default storage size is requested even in the case the PVC storage has a smaller limits configured. This will be rejected later by k8s so it should be ok.
Approved these changes.
Thanks! The replicas are ignored when building the actual STS if HPA is set in a later step 🙏
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5dcb67912
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<sub><sub>!P2 Badge</sub></sub> Validate digest syntax for user-supplied images
When a complete override supplies a nonempty malformed digest such as digest: nope, this validator accepts it, requiresResolution treats the image as complete, and image resolution produces an unusable repository@nope reference; the standalone Worker validator has the same gap. Despite the earlier thread's claimed schema fix, the fresh evidence in the reviewed tree is that both generated CRDs still define digest as an unconstrained string, so validate it as a SHA-256 digest here (and for Worker images), similarly to validateDigest in the resolver.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Validate autoscaling metric/source combinations
When a nonempty metric such as metrics: [{type: Resource}] is supplied, defaulting preserves it and this validator checks only replica bounds. The generated CRD requires type but does not require the corresponding source or prevent multiple source objects, so the parent resource is admitted while the resulting HorizontalPodAutoscaler is rejected; validate that each metric has exactly the source matching its type (and a valid target) for both BYOC and standalone Workers.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5810fb0ddf
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<sub><sub>!P2 Badge</sub></sub> Complete explicitly selected Searcher PVC templates
When a Searcher selects storage.volumeClaimTemplate: {}, Storage is non-nil so this branch leaves the claim empty, unlike the Indexer and pipeline paths that add ReadWriteOnce and a storage request. The shared validator accepts it because exactly one storage type is selected, but Kubernetes rejects the generated PVC for lacking access modes and requested capacity; default the selected template's required fields or reject an incomplete claim.
Useful? React with 👍 / 👎.
Moved all default values into a grouped const block at the top of the file (also applied to the Worker defaults) in 2af8d410.
<sub><sub>!P2 Badge</sub></sub> Reject negative replica counts
When autoscaling is omitted and a BYOC component or standalone Worker specifies replicas: -1, the generated CRDs admit it because the field has no minimum, defaulting preserves it, and this validator accepts it because it only checks the disruption budget. The resulting Deployment or StatefulSet is rejected by Kubernetes, so reject negative replica counts here or add a Minimum=0 schema constraint.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af8d41033
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<sub><sub>!P2 Badge</sub></sub> Validate override repository and tag syntax
When a complete override uses a nonempty but invalid value such as repository: "registry.example.com/UPPER" or tag: "bad/tag", this validator accepts it and requiresResolution considers the image complete. The resolver then copies these strings verbatim into the resulting image reference, so the managed Pod is rejected rather than the parent resource receiving an InvalidConfiguration error. Apply the same repository/tag parsing used by validateReleaseImage to user-supplied overrides (and to standalone Worker images).
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98e9c6bd25
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
levan-m
shuheiktgw
What does this PR do?
Adds the defaults and runtime validation packages for
DatadogBYOCClusterandDatadogObservabilityPipelinesWorker:internal/controller/datadogbyoccluster/defaultsinternal/controller/datadogbyoccluster/validationinternal/controller/datadogobservabilitypipelinesworker/defaultsinternal/controller/datadogobservabilitypipelinesworker/validationNo reconciler calls these packages yet. The upcoming controller PRs will apply defaults first and then validate the defaulted spec before image resolution, so that explicit values are also checked against the defaults they are combined with. Failures will be reported as
InvalidConfiguration.Motivation
These checks run in the reconciler instead of CEL/XValidation so that the CRDs keep working on Kubernetes versions older than 1.25. See https://github.com/DataDog/datadog-operator/pull/3501#discussion_r4080491818.
Checklist
enhancementqa/skip-qalabel---
Jira: CLOUDPREM-889 (Epic: CLOUDPREM-431 / Initiative: LOPS-253)
[CLOUDPREM-889]: https://datadoghq.atlassian.net/browse/CLOUDPREM-889?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ