refactor(store): share resource limits/requests metric generation for pod containers #3207
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
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
RaphSku
<!-- 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_limitsandkube_pod_init_container_resource_requestswere four near-identical copies of the same resource-to-metric conversion. This moves that logic into a sharedcontainerResourceMetricshelper ininternal/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/storepass without modification.This is a follow-up to #3205: the helper takes extra labels, so the container variants pass
nodeand 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 -->