Skip to content

Conversation

@vikram-raj
Copy link
Member

When the plugin state changes (e.g., enabled -> disabled), we must delete the old label combination to prevent stale time series in Prometheus.

@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 Dec 16, 2025
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Jira Issue OCPBUGS-55136, which is invalid:

  • expected the bug to target the "4.22.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:

When the plugin state changes (e.g., enabled -> disabled), we must delete the old label combination to prevent stale time series in Prometheus.

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
Copy link

coderabbitai bot commented Dec 16, 2025

Walkthrough

The changes refactor plugin metric calculation to compute current state rather than reconstruct prior state. The calculatePluginInfo function signature is simplified by removing the lastPluginInfo parameter, and the flow now explicitly removes obsolete Prometheus metric label series before applying new values to prevent stale time series retention.

Changes

Cohort / File(s) Summary
Plugin metrics refactoring
pkg/serverconfig/metrics.go, pkg/serverconfig/metrics_test.go
Updated calculatePluginInfo function signature to accept only consolePlugins parameter, removing lastPluginInfo. Refactored metric calculation logic to compute current state instead of reconstructing prior state. Added explicit removal of obsolete Prometheus label series before applying new values. Updated test expectations to reflect that zero-valued metrics are no longer included in emitted output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Function signature change: The calculatePluginInfo method signature has been altered (removed lastPluginInfo parameter). Verify all call sites throughout the codebase are updated accordingly.
  • Stale label deletion logic: Review the implementation of obsolete metric label removal to ensure it correctly identifies and deletes stale Prometheus time series.
  • Test alignment: Verify that test expectation updates accurately reflect the new behavior where zero-state metrics are not exposed, and confirm all edge cases (plugin removal, state changes) are properly covered.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 1bddb7e and 8abb933.

📒 Files selected for processing (2)
  • pkg/serverconfig/metrics.go (3 hunks)
  • pkg/serverconfig/metrics_test.go (0 hunks)
💤 Files with no reviewable changes (1)
  • pkg/serverconfig/metrics_test.go
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/serverconfig/metrics.go
🔇 Additional comments (3)
pkg/serverconfig/metrics.go (3)

142-158: LGTM - Clean approach to preventing stale Prometheus time series.

The implementation correctly:

  1. Calculates fresh plugin state first
  2. Diffs against the previous state to identify stale label combinations
  3. Deletes only the specific series that are no longer valid
  4. Then updates lastPluginInfo before setting new values

This properly handles both scenarios: plugins removed entirely and plugins with changed states (e.g., enabled → disabled).


185-189: Good simplification of function responsibilities.

Removing lastPluginInfo from the signature and making calculatePluginInfo focused solely on computing current state improves separation of concerns. The cleanup logic is now appropriately centralized in updatePluginMetric.


190-232: Implementation logic is sound.

The function correctly builds the current plugin state map, handling all three states (enabled, disabled, notfound) and properly mapping known plugins while grouping unknowns.


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

@openshift-ci openshift-ci bot requested review from Leo6Leo and jhadvig December 16, 2025 14:00
@openshift-ci openshift-ci bot added the component/backend Related to backend label Dec 16, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 16, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vikram-raj
Once this PR has been reviewed and has the lgtm label, please assign therealjon 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

@vikram-raj
Copy link
Member 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 Dec 16, 2025
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Jira Issue OCPBUGS-55136, 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 (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

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.

@openshift-ci openshift-ci bot requested a review from yapei December 16, 2025 14:01
@Leo6Leo
Copy link
Contributor

Leo6Leo commented Dec 18, 2025

/retest-required

1 similar comment
@Leo6Leo
Copy link
Contributor

Leo6Leo commented Dec 22, 2025

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 22, 2025

@vikram-raj: 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

component/backend Related to backend 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.

3 participants