← Back to Pull requests

refactor(store): share resource limits/requests metric generation for pod containers #3207

Open
unknown opened this pull request with 267 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 12, 2026 10:32 UTC
Author

<!-- markdownlint-disable-next-line MD041 -->
What this PR does / why we need it:

The generators for kube_pod_container_resource_limits, kube_pod_container_resource_requests, kube_pod_init_container_resource_limits and kube_pod_init_container_resource_requests were four near-identical copies of the same resource-to-metric conversion. This moves that logic into a shared containerResourceMetrics helper in internal/store/pod.go, which takes the containers, a selector for limits or requests, and extra label keys/values.

Emitted metrics are unchanged: same metric names, label sets, values and units (CPU in cores, storage/ephemeral-storage/memory/hugepages/attachable volumes in bytes, extended resources as integer). Existing tests in internal/store pass without modification.

This is a follow-up to #3205: the helper takes extra labels, so the container variants pass node and the init-container variants, which no longer have it since #3205, pass none.

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)

Does not change cardinality.

Which issue(s) this PR fixes: (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged)

None, refactor only. Related to #3205.

🤖 Generated with Claude Code

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->

Summary by CodeRabbit

Monitoring
Container and init-container resource metrics report CPU in cores, memory and storage-related resources in bytes, and extended resources in integer units.
Metrics now include huge-page and attachable-volume resources for both regular and init containers. Huge-page resources that are also classified as extended resources may be reported in both byte and integer units.
Container metrics include the node label and pod node name; init-container metrics add no extra labels. Unsupported resource types are skipped.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 267 lines (+200 / -67) across 3 files Reviewer: RaphSku Review duration: 26120m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 267 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
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
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.334
Real PR Conversation Timeline
1 comments
"Review active on #3207"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
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: 39.4% (MEDIUM) · Higher = larger blast radius
39.4%
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: 46.7% · Lower = rushed or shallow review
46.7%
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: 21.0% · Safe to merge
21.0%