Add env var overrides for controller enable flags#3097
Closed
savec80 wants to merge 1 commit into
Closed
Conversation
OLM deployments cannot override container args — only env vars via Subscription.spec.config.env. This adds env var fallback for all 12 controller-enable boolean flags, applied before flag.Parse() so that explicit CLI flags still take precedence (default < env < CLI). Updated feature docs with OLM env var examples and added a full flag/env-var reference table to docs/installation.md. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
🛑 Gate Violations
|
hestonhoffman
approved these changes
Jun 5, 2026
6 tasks
Member
|
Hello, thank you for the contribution! I'm closing this PR in favour of #3181 (using your commit to preserve authorship) to allow CI to run, and we'll discuss with the team if we go forward. I made small tweaks to it, but the general idea stands. Please note commits need to be signed, so while I did use your commit, I might eventually re-write it to have it signed otherwise the PR cannot be merged. Regards, |
tbavelier
added a commit
that referenced
this pull request
Jun 25, 2026
>[!NOTE] > This PR is created by pushing locally the commits from #3097 for the purpose of CI. Original commits are preserved with authorship. >[!IMPORTANT] > This PR now goes beyond the original controller-only boolean env-var fallback. It centralizes environment override parsing through a small typed helper so options can share the same precedence model: compiled default < environment variable < CLI flag. > > The updated implementation supports boolean, string, integer, and duration env vars, while still applying them before `flag.Parse()` so explicit CLI arguments win. In addition to the controller enable flags, it now covers selected non-EDS startup options such as metrics binding, secure metrics, profiling, pprof, leader election, Cilium support, maximum goroutines, controller revisions, and the untaint controller's CSI readiness gate. > > EDS flags, log flags, secret backend flags, and `--version` remain CLI-only. Tests were added for env-over-default behavior, CLI-over-env precedence, and invalid env values preserving defaults. ### `cmd/main.go` - Added `boolFromEnv` helper using `os.LookupEnv` + `strconv.ParseBool` - 12 env var overrides applied before `flag.Parse()` so CLI flags take precedence - Invalid values logged to stderr (logger is not initialized at parse time) ### Documentation | Doc | Env var documented | |-----|--------------------| | `docs/installation.md` | Full reference table with all 12 flags | | `docs/untaint_controller.md` | `DD_UNTAINT_CONTROLLER_ENABLED` | | `docs/datadog_agent_profiles.md` | `DD_AGENT_PROFILE_CONTROLLER_ENABLED` | | `docs/introspection.md` | `DD_INTROSPECTION_ENABLED` | | `docs/control_plane_monitoring.md` | `DD_INTROSPECTION_ENABLED` (OLM alternative to CSV patch) | | `docs/datadog_dashboard.md` | `DD_DASHBOARD_CONTROLLER_ENABLED` | | `docs/datadog_monitor.md` | `DD_MONITOR_CONTROLLER_ENABLED` | | `docs/datadog_slo.md` | `DD_SLO_CONTROLLER_ENABLED` | | `docs/datadog_generic_resource.md` | `DD_GENERIC_RESOURCE_CONTROLLER_ENABLED` | ## Test plan - [x] `go build ./cmd/main.go` passes - [x] `go test ./cmd/...` passes - [x] `go vet ./cmd/...` clean - [ ] Set `DD_DASHBOARD_CONTROLLER_ENABLED=true` on operator pod, verify controller starts - [ ] Set invalid value (e.g. `yes`), verify stderr error message - [ ] Set env var + CLI flag, verify CLI flag wins Original commits: * f899bf9 Add env var overrides for controller enable flags * bbdc4b5 Add more options + use small generic helper to parse multiple types + tests * a050c22 Merge branch 'main' into savec80/feat/env-var-controller-flags * c04e806 Update docs/control_plane_monitoring.md * c226883 Update docs/installation.md * 06f778f Update docs/installation.md * ea9586c Update docs/installation.md * b6e7ad0 Update docs/control_plane_monitoring.md * 7ab35d3 Merge branch 'main' into savec80/feat/env-var-controller-flags Signed-off-by: Timothée Bavelier <[email protected]>
tbavelier
added a commit
that referenced
this pull request
Jun 25, 2026
* Add env var overrides for controller enable flags (#3181) >[!NOTE] > This PR is created by pushing locally the commits from #3097 for the purpose of CI. Original commits are preserved with authorship. >[!IMPORTANT] > This PR now goes beyond the original controller-only boolean env-var fallback. It centralizes environment override parsing through a small typed helper so options can share the same precedence model: compiled default < environment variable < CLI flag. > > The updated implementation supports boolean, string, integer, and duration env vars, while still applying them before `flag.Parse()` so explicit CLI arguments win. In addition to the controller enable flags, it now covers selected non-EDS startup options such as metrics binding, secure metrics, profiling, pprof, leader election, Cilium support, maximum goroutines, controller revisions, and the untaint controller's CSI readiness gate. > > EDS flags, log flags, secret backend flags, and `--version` remain CLI-only. Tests were added for env-over-default behavior, CLI-over-env precedence, and invalid env values preserving defaults. ### `cmd/main.go` - Added `boolFromEnv` helper using `os.LookupEnv` + `strconv.ParseBool` - 12 env var overrides applied before `flag.Parse()` so CLI flags take precedence - Invalid values logged to stderr (logger is not initialized at parse time) ### Documentation | Doc | Env var documented | |-----|--------------------| | `docs/installation.md` | Full reference table with all 12 flags | | `docs/untaint_controller.md` | `DD_UNTAINT_CONTROLLER_ENABLED` | | `docs/datadog_agent_profiles.md` | `DD_AGENT_PROFILE_CONTROLLER_ENABLED` | | `docs/introspection.md` | `DD_INTROSPECTION_ENABLED` | | `docs/control_plane_monitoring.md` | `DD_INTROSPECTION_ENABLED` (OLM alternative to CSV patch) | | `docs/datadog_dashboard.md` | `DD_DASHBOARD_CONTROLLER_ENABLED` | | `docs/datadog_monitor.md` | `DD_MONITOR_CONTROLLER_ENABLED` | | `docs/datadog_slo.md` | `DD_SLO_CONTROLLER_ENABLED` | | `docs/datadog_generic_resource.md` | `DD_GENERIC_RESOURCE_CONTROLLER_ENABLED` | ## Test plan - [x] `go build ./cmd/main.go` passes - [x] `go test ./cmd/...` passes - [x] `go vet ./cmd/...` clean - [ ] Set `DD_DASHBOARD_CONTROLLER_ENABLED=true` on operator pod, verify controller starts - [ ] Set invalid value (e.g. `yes`), verify stderr error message - [ ] Set env var + CLI flag, verify CLI flag wins Original commits: * f899bf9 Add env var overrides for controller enable flags * bbdc4b5 Add more options + use small generic helper to parse multiple types + tests * a050c22 Merge branch 'main' into savec80/feat/env-var-controller-flags * c04e806 Update docs/control_plane_monitoring.md * c226883 Update docs/installation.md * 06f778f Update docs/installation.md * ea9586c Update docs/installation.md * b6e7ad0 Update docs/control_plane_monitoring.md * 7ab35d3 Merge branch 'main' into savec80/feat/env-var-controller-flags Signed-off-by: Timothée Bavelier <[email protected]> * Address env var docs for CLI-pinned flags --------- Signed-off-by: Timothée Bavelier <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
cmd/main.goboolFromEnvhelper usingos.LookupEnv+strconv.ParseBoolflag.Parse()so CLI flags take precedenceDocumentation
docs/installation.mddocs/untaint_controller.mdDD_UNTAINT_CONTROLLER_ENABLEDdocs/datadog_agent_profiles.mdDD_AGENT_PROFILE_CONTROLLER_ENABLEDdocs/introspection.mdDD_INTROSPECTION_ENABLEDdocs/control_plane_monitoring.mdDD_INTROSPECTION_ENABLED(OLM alternative to CSV patch)docs/datadog_dashboard.mdDD_DASHBOARD_CONTROLLER_ENABLEDdocs/datadog_monitor.mdDD_MONITOR_CONTROLLER_ENABLEDdocs/datadog_slo.mdDD_SLO_CONTROLLER_ENABLEDdocs/datadog_generic_resource.mdDD_GENERIC_RESOURCE_CONTROLLER_ENABLEDTest plan
go build ./cmd/main.gopassesgo test ./cmd/...passesgo vet ./cmd/...cleanDD_DASHBOARD_CONTROLLER_ENABLED=trueon operator pod, verify controller startsyes), verify stderr error message