Skip to content

OCPBUGS-60905, OCPBUGS-51196, OCPBUGS-51181: fix(metrics): metrics export through service works now#268

Open
Cali0707 wants to merge 6 commits into
openshift:masterfrom
Cali0707:fix-metrics-svc-selector
Open

OCPBUGS-60905, OCPBUGS-51196, OCPBUGS-51181: fix(metrics): metrics export through service works now#268
Cali0707 wants to merge 6 commits into
openshift:masterfrom
Cali0707:fix-metrics-svc-selector

Conversation

@Cali0707

@Cali0707 Cali0707 commented Jun 16, 2026

Copy link
Copy Markdown

The service monitor and service for metrics did not match the labels on the deployment correctly. This seems to date back to when they were first added.

Summary by CodeRabbit

  • New Features

    • Secured operator metrics with HTTPS on port 8443, including TLS certificate mounting.
    • Added a dedicated metrics Service and Prometheus RBAC permissions so Prometheus can read required resources.
    • Added an integration test validating Prometheus returns operator metrics.
  • Bug Fixes

    • Updated Prometheus ServiceMonitor selection to match the metrics Service using the correct label key.
  • Chores

    • Enabled the metrics auth-proxy Service and updated the proxy role binding to use the operator ServiceAccount.
    • Changed the default metrics bind address to :8443.

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

The service monitor and service for metrics did not match the labels on the deployment correctly. This seems to date back to when they were first added.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The operator metrics endpoint transitions from plain HTTP on port 8080 to HTTPS on port 8443, with TLS certificates mounted into the application. Service and Prometheus ServiceMonitor labels are renamed for consistent discovery, the auth proxy service is activated in Kustomization, RBAC bindings are updated to use the correct service account, and the controller reconciles Prometheus Role and RoleBinding resources. Integration testing validates the entire flow.

Changes

Secure Prometheus Metrics with RBAC

Layer / File(s) Summary
Metrics HTTPS serving infrastructure
main.go, config/manager/manager.yaml, bundle/manifests/update-service-operator.clusterserviceversion.yaml, bundle/manifests/updateservice-operator-metrics_v1_service.yaml
Application metrics bind address changes from :8080 to :8443; controller-runtime metrics config enables SecureServing: true with CertDir: /etc/metrics-certs; both Deployment and ClusterServiceVersion expose port 8443 named https and mount the updateservice-operator-metrics-tls secret as read-only volume; new Service manifest created for updateservice-operator-metrics endpoint.
Service discovery label standardization
config/rbac/auth_proxy_service.yaml, config/prometheus/monitor.yaml
Service metadata.labels and spec.selector, and ServiceMonitor metadata.labels and spec.selector.matchLabels, switch label key from control-plane to name with value updateservice-operator for consistent Prometheus operator discovery.
RBAC configuration and permissions
config/rbac/kustomization.yaml, config/rbac/auth_proxy_role_binding.yaml, config/rbac/role.yaml, bundle/manifests/update-service-operator.clusterserviceversion.yaml
Auth proxy service is uncommented in Kustomization resources list; ClusterRoleBinding proxy-rolebinding updates subject ServiceAccount from controller-manager/system to updateservice-operator/openshift-update-service; ClusterRole gains read/list/watch on rbac.authorization.k8s.io roles and rolebindings; namespaced Role gains create/delete/get/list/patch/update/watch on the same resources; ClusterServiceVersion RBAC rules expanded to include matching permissions and createdAt timestamp updated.
Controller Prometheus RBAC reconciliation
controllers/names.go, controllers/new.go, controllers/updateservice_controller.go, controllers/testdata/resources/zz_fixture_*.yaml
Prometheus naming constants and helper functions added; kubeResources struct extended with prometheusRole and prometheusRoleBinding fields; newPrometheusRole and newPrometheusRoleBinding builders create Role with read/list/watch on services/endpoints/pods and binding to prometheus-k8s in openshift-monitoring namespace; controller imports rbacv1, updates kubebuilder RBAC annotations, adds ensurePrometheusRole and ensurePrometheusRoleBinding reconciliation methods, wires them into reconcile loop, and extends SetupWithManager ownership declarations; test fixtures updated with generated resource manifests.
Testing and integration validation
controllers/new_test.go, functests/prometheus_metrics_test.go
Test fixture mapping updated to include prometheus role and role binding fixtures; new integration test verifies Prometheus StatefulSet readiness, applies ServiceMonitor manifest, discovers authenticated Prometheus endpoint via thanos-querier route, builds TLS client from kubeconfig, and polls metrics query until up{service="updateservice-operator-metrics"} succeeds; includes cleanup and skip logic for unavailable Prometheus.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
No-Weak-Crypto ❌ Error Found insecure TLS certificate verification disabled (Insecure: true) in test code at functests/prometheus_metrics_test.go:99, allowing potential MITM attacks. Replace Insecure: true with proper TLS certificate verification or use appropriate CA bundle configuration for test environment.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning TestPrometheusMetrics uses unavailable MicroShift APIs: openshift-monitoring namespace, prometheus-k8s StatefulSet, ServiceMonitor CRD, thanos-querier Route. Test lacks required MicroShift protecti... Add [Skipped:MicroShift] label to test name or guard with exutil.IsMicroShiftCluster() check, or add [apigroup:operators.coreos.com] tag for ServiceMonitor CRD usage.
Test Structure And Quality ❓ Inconclusive Custom check requires reviewing "Ginkgo test code" but the codebase uses Go's standard testing package (testing.T), not Ginkgo. No Ginkgo imports or patterns found. Clarify whether the check should evaluate standard Go tests using testing.T instead of Ginkgo-specific patterns, or if Ginkgo tests exist elsewhere in the codebase.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The custom check specifies Ginkgo test name requirements, but this project uses standard Go testing (func TestName(t *testing.T)), not Ginkgo. No Ginkgo dependencies found in go.mod or Ginkgo test...
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new test is a standard Go test (func TestPrometheusMetrics), not a Ginkgo e2e test with It/Describe/Context/When patterns. Check scope is limited to Ginkgo e2e tests and is not applicable here.
Topology-Aware Scheduling Compatibility ✅ Passed Deployment uses percentages for rolling updates (maxUnavailable: 50%, maxSurge: 100%) not requiring 3+ nodes. PDB is topology-aware (minAvailable: 0 for 1 replica, 1 for 2+). No affinity constraint...
Ote Binary Stdout Contract ✅ Passed No OTE Binary Stdout Contract violations detected. All Go code properly handles logging: test-level logging uses t.Log/t.Logf/t.Fatal/t.Skipf (intercepted by framework), main uses zap logger to std...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New test TestPrometheusMetrics uses DNS hostnames from OpenShift routes (not bare IPv4/IPv6), accesses only cluster-internal services, and skips gracefully when Prometheus unavailable—compatible wi...
Container-Privileges ✅ Passed No container privilege escalation settings detected. No instances of privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN capabilities, allowPrivilegeEscalation: true, or runAsUser: 0 found i...
No-Sensitive-Data-In-Logs ✅ Passed All logging statements in the PR (main.go metrics config, Prometheus RBAC controller methods, and prometheus_metrics_test.go) contain only non-sensitive operational data: versions, namespaces, reso...
Title check ✅ Passed The title matches the main change: fixing metrics export through the service.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@wking

wking commented Jun 16, 2026

Copy link
Copy Markdown
Member

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@wking: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
config/manager/manager.yaml (1)

29-56: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Harden the operator container policy defaults.

At Line 29 onward, the container still lacks explicit securityContext hardening (runAsNonRoot, allowPrivilegeEscalation: false, readOnlyRootFilesystem) and explicit CPU/memory limits. This can violate cluster policy and weaken runtime isolation.

As per coding guidelines, "securityContext: runAsNonRoot, readOnlyRootFilesystem, allowPrivilegeEscalation: false" and "Resource limits (cpu, memory) on every container" are required for Kubernetes manifests.

Suggested patch
       containers:
         - name: updateservice-operator
@@
+          securityContext:
+            runAsNonRoot: true
+            allowPrivilegeEscalation: false
+            readOnlyRootFilesystem: true
+            capabilities:
+              drop:
+                - ALL
+          resources:
+            requests:
+              cpu: 50m
+              memory: 128Mi
+            limits:
+              cpu: 500m
+              memory: 512Mi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/manager/manager.yaml` around lines 29 - 56, The updateservice-operator
container definition lacks required security hardening and resource limits. Add
a securityContext field to the container spec with runAsNonRoot set to true,
allowPrivilegeEscalation set to false, and readOnlyRootFilesystem set to true.
Additionally, add a resources field with CPU and memory limits to comply with
Kubernetes manifest coding guidelines and enforce runtime isolation. These
should be added as direct properties of the container specification within the
spec.template.spec.containers array.

Sources: Coding guidelines, Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@config/manager/manager.yaml`:
- Around line 29-56: The updateservice-operator container definition lacks
required security hardening and resource limits. Add a securityContext field to
the container spec with runAsNonRoot set to true, allowPrivilegeEscalation set
to false, and readOnlyRootFilesystem set to true. Additionally, add a resources
field with CPU and memory limits to comply with Kubernetes manifest coding
guidelines and enforce runtime isolation. These should be added as direct
properties of the container specification within the
spec.template.spec.containers array.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 075a3fb7-8292-4360-b98d-6e3d5cf626b9

📥 Commits

Reviewing files that changed from the base of the PR and between 87f8fd5 and cec294b.

📒 Files selected for processing (7)
  • bundle/manifests/update-service-operator.clusterserviceversion.yaml
  • config/manager/manager.yaml
  • config/prometheus/monitor.yaml
  • config/rbac/auth_proxy_role_binding.yaml
  • config/rbac/auth_proxy_service.yaml
  • config/rbac/kustomization.yaml
  • main.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • config/rbac/auth_proxy_service.yaml
  • config/prometheus/monitor.yaml

@Cali0707
Cali0707 force-pushed the fix-metrics-svc-selector branch from cec294b to f893143 Compare June 17, 2026 15:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
config/manager/manager.yaml (2)

29-52: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add explicit container securityContext hardening.

Line 29 configures the workload container but does not set runAsNonRoot, allowPrivilegeEscalation: false, readOnlyRootFilesystem, or capability drops. This leaves pod security posture dependent on cluster defaults.

Suggested patch
       containers:
         - name: updateservice-operator
           image: controller:latest
           imagePullPolicy: Always
+          securityContext:
+            runAsNonRoot: true
+            allowPrivilegeEscalation: false
+            readOnlyRootFilesystem: true
+            capabilities:
+              drop:
+                - ALL

As per coding guidelines, "securityContext: runAsNonRoot, readOnlyRootFilesystem, allowPrivilegeEscalation: false" and "Drop ALL capabilities, add only what is required".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/manager/manager.yaml` around lines 29 - 52, Add a securityContext
field to the updateservice-operator container to enforce security hardening. The
securityContext should include runAsNonRoot set to true,
allowPrivilegeEscalation set to false, and readOnlyRootFilesystem set to true.
Additionally, configure the securityContext to drop all Linux capabilities using
the capabilities field with DROP: ["ALL"] and only add back any capabilities
that are strictly required for the operator to function. This should be added at
the same indentation level as the env, ports, and volumeMounts fields within the
container specification.

Sources: Coding guidelines, Linters/SAST tools


29-52: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Define container resources and health probes.

Line 29 configures the container without CPU/memory limits and without readiness/liveness probes, which weakens scheduling safety and recovery behavior under load or startup failures.

As per coding guidelines, "Resource limits (cpu, memory) on every container" and "Liveness + readiness probes defined".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/manager/manager.yaml` around lines 29 - 52, The updateservice-operator
container is missing resource limits and health probes required by coding
guidelines. Add a resources section with cpu and memory requests and limits
after the env section. Add both livenessProbe and readinessProbe sections after
the ports section, configuring them to perform HTTP probes against the https
port (8443) to ensure proper scheduling and recovery behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@config/manager/manager.yaml`:
- Around line 29-52: Add a securityContext field to the updateservice-operator
container to enforce security hardening. The securityContext should include
runAsNonRoot set to true, allowPrivilegeEscalation set to false, and
readOnlyRootFilesystem set to true. Additionally, configure the securityContext
to drop all Linux capabilities using the capabilities field with DROP: ["ALL"]
and only add back any capabilities that are strictly required for the operator
to function. This should be added at the same indentation level as the env,
ports, and volumeMounts fields within the container specification.
- Around line 29-52: The updateservice-operator container is missing resource
limits and health probes required by coding guidelines. Add a resources section
with cpu and memory requests and limits after the env section. Add both
livenessProbe and readinessProbe sections after the ports section, configuring
them to perform HTTP probes against the https port (8443) to ensure proper
scheduling and recovery behavior.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: bccc308f-2e9c-462a-9259-d0c3e56d6ba3

📥 Commits

Reviewing files that changed from the base of the PR and between cec294b and f893143.

📒 Files selected for processing (8)
  • bundle/manifests/update-service-operator.clusterserviceversion.yaml
  • bundle/manifests/updateservice-operator-metrics_v1_service.yaml
  • config/manager/manager.yaml
  • config/prometheus/monitor.yaml
  • config/rbac/auth_proxy_role_binding.yaml
  • config/rbac/auth_proxy_service.yaml
  • config/rbac/kustomization.yaml
  • main.go
✅ Files skipped from review due to trivial changes (1)
  • config/rbac/auth_proxy_service.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • bundle/manifests/update-service-operator.clusterserviceversion.yaml
  • config/rbac/auth_proxy_role_binding.yaml
  • main.go
  • config/prometheus/monitor.yaml
  • config/rbac/kustomization.yaml

@Cali0707 Cali0707 changed the title OCPBUGS-60905: fix(metrics): align service selector with deployment OCPBUGS-60905: fix(metrics): fix metrics export through service Jun 17, 2026
@Cali0707 Cali0707 changed the title OCPBUGS-60905: fix(metrics): fix metrics export through service OCPBUGS-60905: fix(metrics): metrics export through service works now Jun 17, 2026
@Cali0707

Copy link
Copy Markdown
Author

/verified by @Cali0707, running a cluster bot with this PR checked out:

oc port-forward svc/updateservice-operator-metrics -n install-osus-here 8443:8443
curl -sk https://localhost:8443/metrics
# HELP certwatcher_read_certificate_errors_total Total number of certificate read errors
# TYPE certwatcher_read_certificate_errors_total counter
certwatcher_read_certificate_errors_total 0
<skipping for brevity>
workqueue_work_duration_seconds_count{name="updateservice"} 0

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This PR has been marked as verified by @Cali0707,running a cluster bot with this PR checked out:.

Details

In response to this:

/verified by @Cali0707, running a cluster bot with this PR checked out:

oc port-forward svc/updateservice-operator-metrics -n install-osus-here 8443:8443
curl -sk https://localhost:8443/metrics
# HELP certwatcher_read_certificate_errors_total Total number of certificate read errors
# TYPE certwatcher_read_certificate_errors_total counter
certwatcher_read_certificate_errors_total 0
<skipping for brevity>
workqueue_work_duration_seconds_count{name="updateservice"} 0

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 openshift-eng/jira-lifecycle-plugin repository.

@Cali0707

Copy link
Copy Markdown
Author

/cc @wking

@openshift-ci
openshift-ci Bot requested a review from wking June 17, 2026 17:15
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jun 17, 2026
@Cali0707 Cali0707 changed the title OCPBUGS-60905: fix(metrics): metrics export through service works now OCPBUGS-60905, OCPBUGS-51196: fix(metrics): metrics export through service works now Jun 17, 2026
@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

The bug has been updated to refer to the pull request using the external bug tracker.

This pull request references Jira Issue OCPBUGS-51196, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

The service monitor and service for metrics did not match the labels on the deployment correctly. This seems to date back to when they were first added.

Summary by CodeRabbit

  • New Features

  • Secured operator metrics with HTTPS by exposing an additional 8443 port and wiring TLS certificates into the metrics endpoint.

  • Added a dedicated metrics Service that serves metrics over HTTPS.

  • Bug Fixes

  • Updated Prometheus ServiceMonitor selection to consistently target the intended metrics Service.

  • Chores

  • Enabled the metrics-related auth-proxy service in the RBAC configuration.

  • Updated the proxy role binding to use the operator’s ServiceAccount.

  • Changed the default metrics bind address to :8443.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Jun 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

This pull request references Jira Issue OCPBUGS-51196, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

Details

In response to this:

The service monitor and service for metrics did not match the labels on the deployment correctly. This seems to date back to when they were first added.

Summary by CodeRabbit

  • New Features

  • Secured operator metrics with HTTPS by exposing port 8443 and wiring TLS certificates into the metrics endpoint.

  • Added a dedicated HTTPS metrics Service and RBAC needed for Prometheus to read required resources.

  • Bug Fixes

  • Updated Prometheus ServiceMonitor matching to reliably target the intended metrics Service.

  • Chores

  • Enabled the metrics-related auth-proxy Service and adjusted the proxy role binding to use the operator ServiceAccount.

  • Changed the default metrics bind address to :8443.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jun 17, 2026
@Cali0707

Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

This pull request references Jira Issue OCPBUGS-51196, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@Cali0707

Copy link
Copy Markdown
Author

/verified by @Cali0707, curling the metrics svc on a cluster bot cluster

@shahsahil264 shahsahil264 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2026
@openshift-ci

openshift-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Cali0707, shahsahil264
Once this PR has been reviewed and has the lgtm label, please assign hongkailiu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@Cali0707

Copy link
Copy Markdown
Author

prometheus_metrics_test.go:146: Prometheus returned 401: Unauthorized

Looks like I need to figure out how to get auth for the Prometheus instance within this job properly...

@Cali0707
Cali0707 force-pushed the fix-metrics-svc-selector branch from cbca6c4 to 8613e58 Compare June 18, 2026 13:48
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2026
@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@Cali0707
Cali0707 force-pushed the fix-metrics-svc-selector branch from 9535fbc to 3bab9a7 Compare June 18, 2026 19:53
@Cali0707

Copy link
Copy Markdown
Author

/cc @wking

Lmk what else is needed here

@rexagod rexagod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👋🏼 Hello, I left a few comments around a bug that popped up during the current RIT rotation. If they make sense, please add the linked bug below to the PR title. I've also assigned you to the same ticket.

OperatorNamespace string
}

// +kubebuilder:rbac:groups="",resources=configmaps;pods;services;secrets,verbs=get;list;watch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:rbac:groups="",resources=namespaces;configmaps;pods;services;secrets,verbs=get;list;watch

ns.Labels = map[string]string{}
}
if ns.Labels["openshift.io/cluster-monitoring"] != "true" {
ns.Labels["openshift.io/cluster-monitoring"] = "true"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIUC, this is not done by the controller in production, causing https://redhat.atlassian.net/browse/OCPBUGS-51181.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think the issue is we were missing some operator CSV labels - my understanding is that the console looks at those to determine what should be shown: https://github.com/openshift/console/blob/6d0dcf1d76337e46d95ea1b546d5ffe692d7918d/frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-subscribe.tsx#L225-L226

The console actually labels the ns itself

That said, I added the required labels into this branch 😄

@Cali0707
Cali0707 force-pushed the fix-metrics-svc-selector branch from 3bab9a7 to f9ca058 Compare July 21, 2026 17:43
@Cali0707 Cali0707 changed the title OCPBUGS-60905, OCPBUGS-51196: fix(metrics): metrics export through service works now OCPBUGS-60905, OCPBUGS-51196, OCPBUGS-51181: fix(metrics): metrics export through service works now Jul 21, 2026
@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jul 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

The bug has been updated to refer to the pull request using the external bug tracker.

This pull request references Jira Issue OCPBUGS-51196, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

The bug has been updated to refer to the pull request using the external bug tracker.

This pull request references Jira Issue OCPBUGS-51181, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

The service monitor and service for metrics did not match the labels on the deployment correctly. This seems to date back to when they were first added.

Summary by CodeRabbit

  • New Features

  • Secured operator metrics with HTTPS on port 8443, including TLS certificate mounting.

  • Added a dedicated metrics Service and Prometheus RBAC permissions so Prometheus can read required resources.

  • Added an integration test validating Prometheus returns operator metrics.

  • Bug Fixes

  • Updated Prometheus ServiceMonitor selection to match the metrics Service using the correct label key.

  • Chores

  • Enabled the metrics auth-proxy Service and updated the proxy role binding to use the operator ServiceAccount.

  • Changed the default metrics bind address to :8443.

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 openshift-eng/jira-lifecycle-plugin repository.

@Cali0707

Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@Cali0707: This pull request references Jira Issue OCPBUGS-60905, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

This pull request references Jira Issue OCPBUGS-51196, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

This pull request references Jira Issue OCPBUGS-51181, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@Cali0707
Cali0707 force-pushed the fix-metrics-svc-selector branch from dba7170 to da505c9 Compare July 21, 2026 18:27

@2uasimojo 2uasimojo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The TLS discovery bits seem sane to me (FWIW).

Comment thread pkg/tlsconfig/tlsconfig.go Outdated

observedConfig, errs := apiserver.ObserveTLSSecurityProfile(listers, recorder, map[string]interface{}{})
if len(errs) > 0 {
return nil, fmt.Errorf("observing TLS security profile: %v", errs[0])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider errors.Wrap() (throughout).

@Cali0707

Copy link
Copy Markdown
Author

/test install-bundle

@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@Cali0707: 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

jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants