Skip to content

[SREP-3287] dynatrace_enabled feature flag#466

Open
aliceh wants to merge 4 commits intoopenshift:masterfrom
aliceh:SREP-3287-dev
Open

[SREP-3287] dynatrace_enabled feature flag#466
aliceh wants to merge 4 commits intoopenshift:masterfrom
aliceh:SREP-3287-dev

Conversation

@aliceh
Copy link
Contributor

@aliceh aliceh commented Feb 10, 2026

  • Dynatrace is disabled by default; must explicitly set dynatrace_enabled: "true" to enable
  • Existing deployments without the flag will now have Dynatrace disabled
  • If ConfigMap can't be read or field is missing/invalid, Dynatrace is disabled

Summary by CodeRabbit

  • New Features

    • Integrated Dynatrace Synthetic Monitoring with configurable per-region and per-sector control
    • Added dynamic Dynatrace enablement via ConfigMap-based feature flag
  • Documentation

    • Updated configuration guide documenting ConfigMap fields for HostedCluster monitoring
    • Added Dynatrace enablement instructions with practical examples

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliceh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 10, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 27.27273% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.79%. Comparing base (ea2148c) to head (66ba512).

Files with missing lines Patch % Lines
...ntrollers/hostedcontrolplane/hostedcontrolplane.go 27.27% 16 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #466      +/-   ##
==========================================
- Coverage   55.86%   55.79%   -0.08%     
==========================================
  Files          31       31              
  Lines        2753     2762       +9     
==========================================
+ Hits         1538     1541       +3     
- Misses       1123     1129       +6     
  Partials       92       92              
Files with missing lines Coverage Δ
controllers/hostedcontrolplane/synthetics.go 52.04% <ø> (ø)
...ntrollers/hostedcontrolplane/hostedcontrolplane.go 35.78% <27.27%> (-0.08%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Resolved merge conflict in rmo-config-template.yaml
- Kept both dynatrace-enabled config field and new monitoring resources
- All hostedcontrolplane tests passing

Made-with: Cursor
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Walkthrough

Introduces Dynatrace synthetic monitoring integration for route-monitor-operator via a feature flag (dynatrace-enabled) configurable through ConfigMap. Updates configuration reading to parse the flag, conditionally instantiates Dynatrace API clients, and modifies reconciliation logic to handle Dynatrace resources only when enabled.

Changes

Cohort / File(s) Summary
Documentation & Configuration
README.md, hack/olm-registry/rmo-config-template.yaml
Added documentation on dynamic ConfigMap configuration for Dynatrace monitoring, including per-region/per-sector control. Introduced DYNATRACE_ENABLED parameter and dynatrace-enabled ConfigMap field.
Type Definition
controllers/hostedcontrolplane/synthetics.go
Added new exported DynatraceConfig struct with Enabled bool field as a feature flag, defaulting to false.
Reconciliation Logic
controllers/hostedcontrolplane/hostedcontrolplane.go
Modified getRHOBSConfig() signature to return both RHOBSConfig and DynatraceConfig. Added conditional Dynatrace API client creation based on feature flag; client creation failures gracefully fall back to RHOBS-only when RHOBS is configured. Updated reconciliation, deletion, and deployment paths to conditionally handle Dynatrace resources.
Test Suite
controllers/hostedcontrolplane/hostedcontrolplane_test.go
Updated tests to expect two return values from getRHOBSConfig(). Renamed test expectations to expectedRHOBS and added expectedDynatrace field. Added test cases for Dynatrace enabled/disabled and invalid configuration scenarios.

Sequence Diagram

sequenceDiagram
    participant R as HostedControlPlane<br/>Reconciler
    participant C as ConfigMap<br/>(rmo-config)
    participant D as Dynatrace<br/>API Client
    participant RO as RHOBS<br/>Monitoring

    R->>C: Read configuration from ConfigMap
    C-->>R: Return RHOBS & Dynatrace configs
    
    alt Dynatrace Enabled
        R->>D: Create Dynatrace API client
        alt Client Creation Success
            D-->>R: Client instance
            R->>R: Store dynatraceApiClient
            Note over R: Both RHOBS and Dynatrace<br/>monitoring active
        else Client Creation Fails
            D-->>R: Error
            alt RHOBS Configured
                R->>RO: Continue with RHOBS only
                RO-->>R: Proceed with fallback
            else RHOBS Not Configured
                R->>R: Return fatal error
            end
        end
    else Dynatrace Disabled
        R->>R: Log: Dynatrace monitoring disabled
        R->>RO: Use RHOBS monitoring only
    end
    
    R->>R: Reconcile resources
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning Test assertions on lines 99-101 lack meaningful failure messages, making test failure diagnosis difficult. Add descriptive messages to all Expect() calls, e.g., Expect(rhobsResult).To(Equal(...), "test case failed: RHOBS config mismatch") for clear failure diagnostics.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[SREP-3287] dynatrace_enabled feature flag' clearly and specifically describes the main change: introducing a dynatrace_enabled feature flag for Dynatrace monitoring control in the Route Monitor Operator configuration.
Stable And Deterministic Test Names ✅ Passed All test names in the modified test file are stable and deterministic with no dynamic information that could change between runs.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
controllers/hostedcontrolplane/hostedcontrolplane_test.go (1)

1041-1044: Avoid mutating expected values by test-case name.

This introduces hidden coupling and makes failures harder to reason about. Keep each case self-contained in the table instead.

♻️ Proposed cleanup
-			expectedRHOBS: RHOBSConfig{
-				ProbeAPIURL:        "fallback-api.example.com/probes", // wrong, should be fallback
+			expectedRHOBS: RHOBSConfig{
+				ProbeAPIURL:        "https://fallback-api.example.com/probes",
 				Tenant:             "fallback-tenant",                 // empty/whitespace uses fallback
 				OIDCClientID:       "valid-id",
 				OIDCClientSecret:   "fallback-secret",
 				OIDCIssuerURL:      "https://fallback-issuer.example.com",
 				OnlyPublicClusters: false,
 			},
@@
-			// For the empty values test, we need to fix the expected value
-			if tt.name == "ConfigMap present with empty values - uses fallback for empty fields" {
-				tt.expectedRHOBS.ProbeAPIURL = "https://fallback-api.example.com/probes"
-			}
-
 			if rhobsResult != tt.expectedRHOBS {
 				t.Errorf("getRHOBSConfig() RHOBS got = %+v, want = %+v", rhobsResult, tt.expectedRHOBS)
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@controllers/hostedcontrolplane/hostedcontrolplane_test.go` around lines 1041
- 1044, The test mutates the expected result based on tt.name (the conditional
that sets tt.expectedRHOBS.ProbeAPIURL when tt.name == "ConfigMap present with
empty values - uses fallback for empty fields"), which creates hidden coupling;
remove that conditional and instead set the correct ProbeAPIURL directly in the
test-case table entry for that case (populate expectedRHOBS.ProbeAPIURL =
"https://fallback-api.example.com/probes" in the case struct), ensuring each
case is self-contained and keeping tt, tt.name and tt.expectedRHOBS.ProbeAPIURL
unchanged elsewhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@controllers/hostedcontrolplane/hostedcontrolplane.go`:
- Line 114: The current return of DynatraceConfig{Enabled: false} in the hosted
control plane config code inappropriately disables Dynatrace when the ConfigMap
is unreadable/missing/invalid; change the default to DynatraceConfig{Enabled:
true} unless the ConfigMap explicitly sets the value to the string "false".
Update the code paths that currently return r.RHOBSConfig,
DynatraceConfig{Enabled: false} (and the analogous block around the 138-142
range) to return r.RHOBSConfig, DynatraceConfig{Enabled: true} by default, and
add explicit handling to parse the ConfigMap value into DynatraceConfig.Enabled
so only an explicit "false" disables it; keep references to RHOBSConfig and
DynatraceConfig to locate the changes.

In `@hack/olm-registry/rmo-config-template.yaml`:
- Around line 50-53: The template currently sets the DYNATRACE_ENABLED parameter
default to "false", which makes generated ConfigMaps opt-out; change the default
value for the parameter named DYNATRACE_ENABLED in rmo-config-template.yaml from
"false" to "true" (and keep required: false) so Dynatrace is enabled by default,
and update the description if needed to state that it is enabled by default and
must be explicitly set to "false" to disable.

In `@README.md`:
- Around line 67-68: The README currently says `dynatrace-enabled` defaults to
"false" but the PR requires Dynatrace to be enabled by default; update the field
description for `dynatrace-enabled` to indicate default: "true" and adjust any
examples/usage blocks (referenced around the same section lines and the example
at lines 73-78) so they reflect that Dynatrace is enabled unless explicitly set
to "false" (change wording and example values accordingly).

---

Nitpick comments:
In `@controllers/hostedcontrolplane/hostedcontrolplane_test.go`:
- Around line 1041-1044: The test mutates the expected result based on tt.name
(the conditional that sets tt.expectedRHOBS.ProbeAPIURL when tt.name ==
"ConfigMap present with empty values - uses fallback for empty fields"), which
creates hidden coupling; remove that conditional and instead set the correct
ProbeAPIURL directly in the test-case table entry for that case (populate
expectedRHOBS.ProbeAPIURL = "https://fallback-api.example.com/probes" in the
case struct), ensuring each case is self-contained and keeping tt, tt.name and
tt.expectedRHOBS.ProbeAPIURL unchanged elsewhere.

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between ea2148c and 66ba512.

📒 Files selected for processing (5)
  • README.md
  • controllers/hostedcontrolplane/hostedcontrolplane.go
  • controllers/hostedcontrolplane/hostedcontrolplane_test.go
  • controllers/hostedcontrolplane/synthetics.go
  • hack/olm-registry/rmo-config-template.yaml

logger.V(2).Info("Failed to read ConfigMap, using fallback config", "error", err.Error())
}
return r.RHOBSConfig
return r.RHOBSConfig, DynatraceConfig{Enabled: false}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Dynatrace failover/default logic is reversed from the feature contract.

Current logic disables Dynatrace when the ConfigMap is unreadable, missing, empty, or invalid. Per PR objective, Dynatrace should be enabled unless explicitly set to "false".

🐛 Proposed fix
-		return r.RHOBSConfig, DynatraceConfig{Enabled: false}
+		return r.RHOBSConfig, DynatraceConfig{Enabled: true}
@@
-	// Read Dynatrace configuration - defaults to disabled
-	dynatraceConfig := DynatraceConfig{Enabled: false}
-	if strings.TrimSpace(configMap.Data["dynatrace-enabled"]) == "true" {
-		dynatraceConfig.Enabled = true
-	}
+	// Read Dynatrace configuration - defaults to enabled unless explicitly disabled
+	dynatraceConfig := DynatraceConfig{Enabled: true}
+	if strings.TrimSpace(configMap.Data["dynatrace-enabled"]) == "false" {
+		dynatraceConfig.Enabled = false
+	}

Also applies to: 138-142

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@controllers/hostedcontrolplane/hostedcontrolplane.go` at line 114, The
current return of DynatraceConfig{Enabled: false} in the hosted control plane
config code inappropriately disables Dynatrace when the ConfigMap is
unreadable/missing/invalid; change the default to DynatraceConfig{Enabled: true}
unless the ConfigMap explicitly sets the value to the string "false". Update the
code paths that currently return r.RHOBSConfig, DynatraceConfig{Enabled: false}
(and the analogous block around the 138-142 range) to return r.RHOBSConfig,
DynatraceConfig{Enabled: true} by default, and add explicit handling to parse
the ConfigMap value into DynatraceConfig.Enabled so only an explicit "false"
disables it; keep references to RHOBSConfig and DynatraceConfig to locate the
changes.

Comment on lines +67 to +68
- `dynatrace-enabled`: Enable/disable Dynatrace synthetic monitoring (default: "false")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Dynatrace default behavior in docs is inverted.

This section documents Dynatrace as disabled by default (dynatrace-enabled default "false"), but the PR objective states Dynatrace should be enabled unless explicitly set to "false". Please align the field description and example accordingly.

Also applies to: 73-78

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 67 - 68, The README currently says
`dynatrace-enabled` defaults to "false" but the PR requires Dynatrace to be
enabled by default; update the field description for `dynatrace-enabled` to
indicate default: "true" and adjust any examples/usage blocks (referenced around
the same section lines and the example at lines 73-78) so they reflect that
Dynatrace is enabled unless explicitly set to "false" (change wording and
example values accordingly).

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 3, 2026

@aliceh: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants