← Back to Pull requests

kafka_consumer: skip configured topics missing from the cluster instead of dropping all consumer offsets #25666

Closed
unknown closed this pull request without merging on Oct 21, 2026 11:18 UTC
View on GitHub
unknown unknown commented on Oct 16, 2026 17:38 UTC
Author

What does this PR do?

In explicit consumer_groups mode, if any topic configured as [] (all partitions) is missing from the cluster, the check stops emitting kafka.consumer_offset, kafka.consumer_lag and kafka.estimated_consumer_lag for every group in the instance (and kafka.broker_offset unless monitor_all_broker_highwatermarks is on). The check still reports OK. Since Agent 7.63.0 (kafka_consumer 6.2.0, #19183) it does not recover when the topic is created, and partitions added later to a [] topic never get metrics, until the Agent restarts.

Not affected: monitor_unlisted_consumer_groups, consumer_groups_regex, Kafka Console, or topics with explicit partitions.

Cause: a missing [] topic expands to an empty partition list, cached for the life of the check. confluent-kafka rejects it with ValueError: 'topic_partitions' cannot be empty, which aborted offset collection for all groups.

Fix


  • Remove topic_partition_cache. Partitions for [] topics are read each run from the metadata request_metadata_update already fetches (no extra broker calls). A topic with no partitions is logged and skipped.

  • KafkaClient.list_consumer_group_offsets catches errors per group, so one bad request cannot fail the others.
  • | | Before | After |
    |---|---|---|
    | A [] topic is missing | No offset/lag metrics for any group | Other groups report; warning Topic <topic> configured for consumer group <group> has no partitions in the cluster, skipping it |
    | Topic created later | Nothing until restart | Collected on next run |
    | Partitions added to [] topic | Never picked up until restart | Picked up on next run |

    Test


    test_configured_topic_missing_from_cluster_does_not_block_other_groups and test_configured_topic_created_after_first_run_is_collected in kafka_consumer/tests/test_unit.py run the real check and KafkaClient path, including confluent-kafka's AdminClient validation; only broker responses and the highwater consumer are stubbed. They fail on master and pass here. pytest kafka_consumer/tests -m "not integration and not e2e": 177 passed.

    Motivation

    A typo or not-yet-created topic in consumer_groups silently removes lag monitoring for the whole check instance until the Agent restarts.

    Checklist before requesting review

  • I self-reviewed the full diff, and this description matches the final change

  • Tests cover the change, or this description explains why none are needed

  • Automated review comments, including Codex review, were addressed or answered

  • I, the human author, understand this change, can explain it to reviewers, and believe it meets the repository standards
  • 🤖 Generated with Claude Code

    Diff: 352 lines (+264 / -88) across 4 files Reviewer: HadhemiDD Review duration: 6819m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 352 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #25666"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.7% (HIGH) · Higher = larger blast radius
    65.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.9% · Safe to merge
    25.9%