Skip to content

ROSAENG-64957: Reset ocm_agent_response_failure gauge on alert resolution and resend window - #265

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:masterfrom
aliceh:ROSAENG-64957
Aug 16, 2026
Merged

ROSAENG-64957: Reset ocm_agent_response_failure gauge on alert resolution and resend window#265
openshift-merge-bot[bot] merged 2 commits into
openshift:masterfrom
aliceh:ROSAENG-64957

Conversation

@aliceh

@aliceh aliceh commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes the ocm_agent_response_failure gauge in the fleet RHOBS webhook handler (webhookrhobsreceiver.go) which never resets to 0 after a transient service-log send failure, causing persistent false OCMAgentResponseFailureServiceLogsSRE alerts until the pod is restarted.
  • Adds gauge resets in the two missing code paths: (1) when a non-limited-support alert resolves, and (2) when a firing alert hits the resend window with no active failure — matching the existing behavior of the classic handler in webhookreceiver.go.

Details

The fleet handler sets ocm_agent_response_failure to 1 on failure but omits the reset in two paths:

  1. Alert resolution (non-limited-support): The handler returns early for resolved alerts (!fleetNotification.LimitedSupport && !isCurrentlyFiring → return nil) without clearing the gauge. This change adds metrics.ResetResponseMetricFailure() before the early return.
  2. Resend window (isCurrentlyFiring && !canSend): When a previously-failed alert fires again within the resend window, the gauge stays stuck at 1. This change adds a reset in the else branch of the canSend check.

Jira: https://issues.redhat.com/browse/ROSAENG-64957

Test plan

  • Verify unit tests pass
  • Confirm gauge resets to 0 after alert resolution in fleet mode
  • Confirm gauge resets to 0 during resend window when no active failure exists
  • Validate no regression in classic handler behavior

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Response failure metrics now reset when non-limited-support alerts resolve.
    • Firing alerts that are not eligible for delivery now reset the relevant service-specific failure metrics.

…tion and resend window

The fleet-mode RHOBS webhook handler sets the ocm_agent_response_failure
gauge to 1 on service log send failure but never resets it to 0 in two
code paths, causing persistent false OCMAgentResponseFailureServiceLogsSRE
alerts until the pod is restarted.

Add gauge resets for:
- Resolved non-limited-support alerts (early return path)
- Firing alerts within the resend window (!canSend path)

This matches the existing behavior in the classic handler
(webhookreceiver.go).

Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 12, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 12, 2026

Copy link
Copy Markdown

@aliceh: This pull request references ROSAENG-64957 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Fixes the ocm_agent_response_failure gauge in the fleet RHOBS webhook handler (webhookrhobsreceiver.go) which never resets to 0 after a transient service-log send failure, causing persistent false OCMAgentResponseFailureServiceLogsSRE alerts until the pod is restarted.
  • Adds gauge resets in the two missing code paths: (1) when a non-limited-support alert resolves, and (2) when a firing alert hits the resend window with no active failure — matching the existing behavior of the classic handler in webhookreceiver.go.

Details

The fleet handler sets ocm_agent_response_failure to 1 on failure but omits the reset in two paths:

  1. Alert resolution (non-limited-support): The handler returns early for resolved alerts (!fleetNotification.LimitedSupport && !isCurrentlyFiring → return nil) without clearing the gauge. This change adds metrics.ResetResponseMetricFailure() before the early return.
  2. Resend window (isCurrentlyFiring && !canSend): When a previously-failed alert fires again within the resend window, the gauge stays stuck at 1. This change adds a reset in the else branch of the canSend check.

Jira: https://issues.redhat.com/browse/ROSAENG-64957

Test plan

  • Verify unit tests pass
  • Confirm gauge resets to 0 after alert resolution in fleet mode
  • Confirm gauge resets to 0 during resend window when no active failure exists
  • Validate no regression in classic handler behavior

Made with Cursor

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 review from Tafhim and tkong-redhat August 12, 2026 23:00
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@aliceh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c9cf102-d78f-4455-a596-8212ebd7d9db

📥 Commits

Reviewing files that changed from the base of the PR and between ebda209 and 86a32cd.

📒 Files selected for processing (1)
  • Makefile

Walkthrough

The webhook handler now resets service-specific response failure metrics when non-limited-support alerts resolve or when firing alerts cannot be sent.

Changes

Response metric reset behavior

Layer / File(s) Summary
Reset metrics for resolved and skipped alerts
pkg/handlers/webhookrhobsreceiver.go
Resolved non-limited-support alerts reset the service-log response failure metric. Firing alerts skipped because sending is disallowed reset the clusters or service-log response failure metric.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Mergeability Score: 🔵 Low · up to ebda2

The PR correctly clears the failure gauge in the two identified fleet-handler paths, but a support-mode change during an active alert could leave the earlier labeled gauge set. The change is mergeable with explicit owner awareness or follow-up to confirm or cover that transition behavior.

Suggested reviewers: redhat-chai-bot

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: gauge reset on alert resolution and during the resend window.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 patch changes only pkg/handlers/webhookrhobsreceiver.go; it adds no Ginkgo test declarations or test-title text, dynamic or otherwise.
Test Structure And Quality ✅ Passed The PR changes only pkg/handlers/webhookrhobsreceiver.go; no Ginkgo test files or test setup, waits, resources, or assertions changed, so no stated test-quality failure was introduced.
Microshift Test Compatibility ✅ Passed The pull request changes only pkg/handlers/webhookrhobsreceiver.go; no Ginkgo e2e tests or test declarations were added, so MicroShift compatibility checks do not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The pull request changes only pkg/handlers/webhookrhobsreceiver.go (+9 lines) and adds no Ginkgo e2e tests, so SNO test compatibility is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only metrics-reset logic in pkg/handlers/webhookrhobsreceiver.go; it adds no manifests, controllers, replicas, affinity, topology spread, node selectors, or tolerations.
Ote Binary Stdout Contract ✅ Passed The HEAD diff adds only metric resets in handler logic; ResetResponseMetricFailure writes to Prometheus, not stdout, and no process-level stdout write was introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The diff changes only pkg/handlers/webhookrhobsreceiver.go and adds no Ginkgo e2e tests or test-related files, so IPv6/disconnected test compatibility is not applicable.
No-Weak-Crypto ✅ Passed The PR adds only metric-reset logic in the fleet webhook handler; the added lines introduce no weak crypto, custom crypto, or secret/token comparisons.
Container-Privileges ✅ Passed The PR changes only webhookrhobsreceiver.go metrics logic; no container/Kubernetes manifest changes or privileged settings were introduced.
No-Sensitive-Data-In-Logs ✅ Passed The commit adds only metric-reset logic in one Go file; it introduces no logging calls or sensitive-data log fields.
✨ 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.

@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.

🧹 Nitpick comments (1)
pkg/handlers/webhookrhobsreceiver.go (1)

395-395: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for both reset paths.

Extend pkg/handlers/webhookrhobsreceiver_test.go with tests for a resolved non-limited-support alert and a firing alert where canSend is false. Assert that MetricResponseFailure resets the expected ocm_service, notification_name, and alert_name labels. Include a support-mode transition case if LimitedSupport is mutable during an alert lifecycle.

Also applies to: 481-488

🤖 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 `@pkg/handlers/webhookrhobsreceiver.go` at line 395, Add regression tests in
webhookrhobsreceiver_test.go covering both MetricResponseFailure reset paths: a
resolved non-limited-support alert and a firing alert with canSend false. Assert
resets use the expected ocm_service, notification_name, and alert_name labels,
and cover a LimitedSupport transition during the alert lifecycle if that field
is mutable.
🤖 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.

Nitpick comments:
In `@pkg/handlers/webhookrhobsreceiver.go`:
- Line 395: Add regression tests in webhookrhobsreceiver_test.go covering both
MetricResponseFailure reset paths: a resolved non-limited-support alert and a
firing alert with canSend false. Assert resets use the expected ocm_service,
notification_name, and alert_name labels, and cover a LimitedSupport transition
during the alert lifecycle if that field is mutable.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 81cc3921-6a14-4e9f-945d-ad5ce0cc4e2a

📥 Commits

Reviewing files that changed from the base of the PR and between 8ba784b and ebda209.

📒 Files selected for processing (1)
  • pkg/handlers/webhookrhobsreceiver.go

@codecov-commenter

codecov-commenter commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.46%. Comparing base (8ba784b) to head (86a32cd).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #265      +/-   ##
==========================================
+ Coverage   56.28%   56.46%   +0.18%     
==========================================
  Files          23       23              
  Lines        1926     1934       +8     
==========================================
+ Hits         1084     1092       +8     
  Misses        786      786              
  Partials       56       56              
Files with missing lines Coverage Δ
pkg/handlers/webhookrhobsreceiver.go 91.98% <100.00%> (+0.25%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The CI lint job exceeds the 5m timeout on cold cache runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-ci

openshift-ci Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@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.

@dustman9000

Copy link
Copy Markdown
Member

/lgtm

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

Copy link
Copy Markdown
Contributor

/lgtm

@chamalabey

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliceh, chamalabey

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 Aug 16, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 344eaf5 into openshift:master Aug 16, 2026
13 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants