Skip to content

RHINENG-26549: log kessel errors to external service metric#2262

Merged
dominikvagner merged 1 commit into
RedHatInsights:masterfrom
dominikvagner:patchman-external-service-metric
Jul 8, 2026
Merged

RHINENG-26549: log kessel errors to external service metric#2262
dominikvagner merged 1 commit into
RedHatInsights:masterfrom
dominikvagner:patchman-external-service-metric

Conversation

@dominikvagner

@dominikvagner dominikvagner commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

There is a PatchmanAlertExternalService alert that check if the count of these external service errors is increasing. It used to be tracked for RBAC calls, but not for Kessel. This adds the prometheus counter increments back.

Associated ticket: [RHINENG-26549]

There is a PatchmanAlertExternalService alert that check if the count of
these external service errors is increasing. It used to be tracked for
RBAC calls, but not for Kessel. This adds the prometheus counter
increments back.
@dominikvagner dominikvagner requested a review from a team as a code owner July 8, 2026 12:30
@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds Prometheus external-service error metric logging for Kessel RBAC permission checks by incrementing the shared serviceErrorCnt counter on internal server error paths.

File-Level Changes

Change Details Files
Increment external-service error metric when Kessel permission check fails with internal server errors.
  • Import strconv to convert HTTP status codes to strings for metric labels.
  • On gRPC client creation or setup failures in hasPermissionKessel, increment the serviceErrorCnt counter with service="kessel" and the 500 status code label before returning.
  • On RBAC communication failures in hasPermissionKessel, increment the same serviceErrorCnt counter with service="kessel" and the 500 status code label before returning.
manager/middlewares/kessel.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Hey - I've left some high level feedback:

  • You duplicate the serviceErrorCnt.WithLabelValues("kessel", strconv.Itoa(http.StatusInternalServerError)).Inc() call in both error paths; consider extracting a small helper (e.g., incKesselServiceError(statusCode int)) to keep the labels consistent and make future changes less error-prone.
  • Since we now depend on strconv only to stringify the status code for metrics, you might want to align with any existing pattern in the codebase (e.g., a shared helper or a predefined statusCodeLabel), so metric labels are produced in a uniform way across services.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You duplicate the `serviceErrorCnt.WithLabelValues("kessel", strconv.Itoa(http.StatusInternalServerError)).Inc()` call in both error paths; consider extracting a small helper (e.g., `incKesselServiceError(statusCode int)`) to keep the labels consistent and make future changes less error-prone.
- Since we now depend on `strconv` only to stringify the status code for metrics, you might want to align with any existing pattern in the codebase (e.g., a shared helper or a predefined `statusCodeLabel`), so metric labels are produced in a uniform way across services.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.02%. Comparing base (cc54b11) to head (f11d0b5).

Files with missing lines Patch % Lines
manager/middlewares/kessel.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2262      +/-   ##
==========================================
- Coverage   59.03%   59.02%   -0.02%     
==========================================
  Files         144      144              
  Lines        9194     9196       +2     
==========================================
  Hits         5428     5428              
- Misses       3194     3196       +2     
  Partials      572      572              
Flag Coverage Δ
unittests 59.02% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelMraka MichaelMraka self-assigned this Jul 8, 2026
@dominikvagner dominikvagner merged commit 5c9f07a into RedHatInsights:master Jul 8, 2026
8 checks passed
@dominikvagner dominikvagner deleted the patchman-external-service-metric branch July 8, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants