kafka_consumer: skip configured topics missing from the cluster instead of dropping all consumer offsets #25666
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
HadhemiDD
What does this PR do?
In explicit
consumer_groupsmode, if any topic configured as[](all partitions) is missing from the cluster, the check stops emittingkafka.consumer_offset,kafka.consumer_lagandkafka.estimated_consumer_lagfor every group in the instance (andkafka.broker_offsetunlessmonitor_all_broker_highwatermarksis 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 withValueError: 'topic_partitions' cannot be empty, which aborted offset collection for all groups.Fix
topic_partition_cache. Partitions for[]topics are read each run from the metadatarequest_metadata_updatealready fetches (no extra broker calls). A topic with no partitions is logged and skipped.KafkaClient.list_consumer_group_offsetscatches 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; warningTopic <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_groupsandtest_configured_topic_created_after_first_run_is_collectedinkafka_consumer/tests/test_unit.pyrun the real check andKafkaClientpath, including confluent-kafka'sAdminClientvalidation; 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_groupssilently removes lag monitoring for the whole check instance until the Agent restarts.Checklist before requesting review
🤖 Generated with Claude Code