Skip to content

RHINENG-28970: change error to warning - #2303

Merged
Starle21 merged 1 commit into
RedHatInsights:masterfrom
Starle21:warning
Aug 18, 2026
Merged

Starle21 merged 1 commit into
RedHatInsights:masterfrom
Starle21:warning

Conversation

@Starle21

@Starle21 Starle21 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Downgrade kafka errors that contain 'failed to dial' and show in glitchtip as 'error initializing the kafka reader for partition X' to only warnings. This kind of error should stop appearing in glitchtip.

Testing

Glitchtip should stop surfacing errors starting with "error initializing the kafka reader for partition" such as this one.

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Bug Fixes:

  • Prevent benign Kafka dial failures from being reported as errors in monitoring systems by downgrading them to warnings.

@Starle21
Starle21 requested a review from a team as a code owner August 14, 2026 13:22
@sourcery-ai

sourcery-ai Bot commented Aug 14, 2026

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

Reviewer's Guide

This PR modifies the Kafka logging behavior in the message queue logger so that connection issues containing "failed to dial" are logged as warnings instead of errors, reducing noisy error reporting in Glitchtip while preserving error counting and panic detection for severe issues.

File-Level Changes

Change Details Files
Adjust Kafka message queue logger to downgrade specific connection errors from error-level logs to warnings while keeping existing counter and panic behavior intact.
  • Refactor the logger function to build the log message once using format.Sprintf before logging.
  • Introduce a conditional check for log format strings containing "failed to dial" to route them to utils.LogWarn instead of utils.LogError.
  • Preserve error-level logging for all other messages and keep the existing panic trigger for "Group Load In Progress" unchanged.
base/mqueue/mqueue.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 found 1 issue, and left some high level feedback:

  • The check for "failed to dial" currently uses the format string rather than the formatted message; consider switching the strings.Contains call to use msg so you match the actual logged content, including interpolated values.
  • This change will downgrade any Kafka log that contains "failed to dial" in the format string, not just the specific reader initialization case; if that’s broader than intended, consider tightening the condition (e.g., matching the full message prefix) to avoid unintentionally reclassifying other errors.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The check for "failed to dial" currently uses the format string rather than the formatted message; consider switching the `strings.Contains` call to use `msg` so you match the actual logged content, including interpolated values.
- This change will downgrade any Kafka log that contains "failed to dial" in the format string, not just the specific reader initialization case; if that’s broader than intended, consider tightening the condition (e.g., matching the full message prefix) to avoid unintentionally reclassifying other errors.

## Individual Comments

### Comment 1
<location path="base/mqueue/mqueue.go" line_range="37-38" />
<code_context>
 	fn := func(fmt string, args ...interface{}) {
 		counter.Inc()
-		utils.LogError("type", "kafka", format.Sprintf(fmt, args...))
+		msg := format.Sprintf(fmt, args...)
+		if strings.Contains(fmt, "failed to dial") {
+			utils.LogWarn("type", "kafka", msg)
+		} else {
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use the formatted message for substring checks instead of the raw format string.

Currently, the check uses `strings.Contains(fmt, "failed to dial")` while the log message is built from `msg := format.Sprintf(fmt, args...)`. If "failed to dial" appears only in one of the `args` and not in the format string, the condition won’t match and the message will still be logged as an error. Checking `strings.Contains(msg, "failed to dial")` ensures the log level reflects the actual emitted message and avoids misclassification when the phrase comes from arguments rather than the template.
</issue_to_address>

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.

Comment thread base/mqueue/mqueue.go Outdated
@codecov-commenter

codecov-commenter commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.82%. Comparing base (1906d8e) to head (5696b5b).

Files with missing lines Patch % Lines
base/mqueue/mqueue.go 33.33% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2303      +/-   ##
==========================================
- Coverage   58.83%   58.82%   -0.02%     
==========================================
  Files         150      150              
  Lines        9599     9603       +4     
==========================================
+ Hits         5648     5649       +1     
- Misses       3359     3360       +1     
- Partials      592      594       +2     
Flag Coverage Δ
unittests 58.82% <33.33%> (-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.

Comment thread base/mqueue/mqueue.go Outdated
@TenSt TenSt self-assigned this Aug 14, 2026
@Starle21
Starle21 requested a review from TenSt August 17, 2026 09:02

@TenSt TenSt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

Downgrade kafka errors that contain 'failed to dial' and show in glitchtip
as 'error initializing the kafka reader for partition X' to only warnings.
This kind of error should stop appearing in glitchtip.
@Starle21
Starle21 merged commit 1b72bce into RedHatInsights:master Aug 18, 2026
8 checks passed
@Starle21
Starle21 deleted the warning branch August 18, 2026 08:59
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