← Back to Pull requests

resctrl-mon: accept pod UIDs without dashes too #674

Merged
fmuyassarov merged 5 files (161 lines) on Jun 17, 2026 10:09 UTC
View on GitHub
fmuyassarov fmuyassarov commented on Jun 09, 2026 09:23 UTC
Author

https://github.com/containers/nri-plugins/blob/9b9f6c426d4844e7ff519b8ab75a1b0cd51b1bdc/cmd/plugins/resctrl-mon/resctrl.go#L180
Rework looksLikePodUID() to accept/handle both formats of UUID. In other words, with dashes (current expectation) and without dashes. Because, UUID could be in the format of d9ca284e-f063-4bac-8973-791bcb4a8786 or 74038c4519bd838001f4bee0dc95516d with no separation. Otherwise, we end up failing with mon_group creation for those pods entirely.

Example log snippet before the fix:

time="2026-06-09T08:22:10Z" level=info msg="synchronizing state: 11 pods, 10 containers"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/2ee80e9a-69b0-4cc2-81ab-10066aefc40c for pod 2ee80e9a-69b0-4cc2-81ab-10066aefc40c"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2536642 for pod 2ee80e9a-69b0-4cc2-81ab-10066aefc40c"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/e466768a-a01c-43c4-8c87-415a494dfb68 for pod e466768a-a01c-43c4-8c87-415a494dfb68"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2491796 for pod e466768a-a01c-43c4-8c87-415a494dfb68"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/2f7c0604-eb05-4c95-a9b4-57476dc78c13 for pod 2f7c0604-eb05-4c95-a9b4-57476dc78c13"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2490959 for pod 2f7c0604-eb05-4c95-a9b4-57476dc78c13"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/d9ca284e-f063-4bac-8973-791bcb4a8786 for pod d9ca284e-f063-4bac-8973-791bcb4a8786"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2489907 for pod d9ca284e-f063-4bac-8973-791bcb4a8786"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/585d05d3-a97e-4894-a6b9-1b3d960687a7 for pod 585d05d3-a97e-4894-a6b9-1b3d960687a7"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2489110 for pod 585d05d3-a97e-4894-a6b9-1b3d960687a7"
time="2026-06-09T08:22:10Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/4be23576-26c2-4a05-8cfc-bc57c67b0df8 for pod 4be23576-26c2-4a05-8cfc-bc57c67b0df8"
time="2026-06-09T08:22:10Z" level=debug msg="Synchronize: assigned pid 2485986 for pod 4be23576-26c2-4a05-8cfc-bc57c67b0df8"
time="2026-06-09T08:22:10Z" level=warning msg="Synchronize: failed to create  resctrl monitoring group creation for those pods entirely for pod 9d6530de59bb553c393de789dcfc6da7: invalid pod UID \"9d6530de59bb553c393de789dcfc6da7\""
time="2026-06-09T08:22:10Z" level=warning msg="Synchronize: failed to create mon_group for pod 74038c4519bd838001f4bee0dc95516d: invalid pod UID \"74038c4519bd838001f4bee0dc95516d\""
time="2026-06-09T08:22:10Z" level=warning msg="Synchronize: failed to create mon_group for pod ea0ade74d29d46eaacb5a89c34864be3: invalid pod UID \"ea0ade74d29d46eaacb5a89c34864be3\""
time="2026-06-09T08:22:10Z" level=warning msg="Synchronize: failed to create mon_group for pod 0774f9d04527f4275ff4df1f4d545646: invalid pod UID \"0774f9d04527f4275ff4df1f4d545646\""
time="2026-06-09T08:22:10Z" level=debug msg="background reconciler started (interval=30s)"
time="2026-06-09T08:22:10Z" level=info msg="synchronization complete: tracking 6 pods"

and after

time="2026-06-09T09:11:39Z" level=info msg="synchronizing state: 10 pods, 10 containers"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/4315ea85-bdb6-48dd-8c98-32a311de896d for pod 4315ea85-bdb6-48dd-8c98-32a311de896d"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2756024 for pod 4315ea85-bdb6-48dd-8c98-32a311de896d"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/e466768a-a01c-43c4-8c87-415a494dfb68 for pod e466768a-a01c-43c4-8c87-415a494dfb68"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2491796 for pod e466768a-a01c-43c4-8c87-415a494dfb68"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/2f7c0604-eb05-4c95-a9b4-57476dc78c13 for pod 2f7c0604-eb05-4c95-a9b4-57476dc78c13"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2490959 for pod 2f7c0604-eb05-4c95-a9b4-57476dc78c13"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/d9ca284e-f063-4bac-8973-791bcb4a8786 for pod d9ca284e-f063-4bac-8973-791bcb4a8786"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2489907 for pod d9ca284e-f063-4bac-8973-791bcb4a8786"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/585d05d3-a97e-4894-a6b9-1b3d960687a7 for pod 585d05d3-a97e-4894-a6b9-1b3d960687a7"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2489110 for pod 585d05d3-a97e-4894-a6b9-1b3d960687a7"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/4be23576-26c2-4a05-8cfc-bc57c67b0df8 for pod 4be23576-26c2-4a05-8cfc-bc57c67b0df8"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2485986 for pod 4be23576-26c2-4a05-8cfc-bc57c67b0df8"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/9d6530de59bb553c393de789dcfc6da7 for pod 9d6530de59bb553c393de789dcfc6da7"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2479507 for pod 9d6530de59bb553c393de789dcfc6da7"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/74038c4519bd838001f4bee0dc95516d for pod 74038c4519bd838001f4bee0dc95516d"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2479485 for pod 74038c4519bd838001f4bee0dc95516d"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/ea0ade74d29d46eaacb5a89c34864be3 for pod ea0ade74d29d46eaacb5a89c34864be3"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2479436 for pod ea0ade74d29d46eaacb5a89c34864be3"
time="2026-06-09T09:11:39Z" level=info msg="created mon_group /sys/fs/resctrl/mon_groups/0774f9d04527f4275ff4df1f4d545646 for pod 0774f9d04527f4275ff4df1f4d545646"
time="2026-06-09T09:11:39Z" level=debug msg="Synchronize: assigned pid 2479431 for pod 0774f9d04527f4275ff4df1f4d545646"
time="2026-06-09T09:11:39Z" level=info msg="removing orphaned mon_group /sys/fs/resctrl/mon_groups/2ee80e9a-69b0-4cc2-81ab-10066aefc40c"
time="2026-06-09T09:11:39Z" level=debug msg="background reconciler started (interval=30s)"
time="2026-06-09T09:11:39Z" level=info msg="synchronization complete: tracking 10 pods"

Diff: 161 lines (+120 / -41) across 5 files Reviewer: cmcantalupo Review duration: 11565m
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.39) × (1 − Review Confidence (0.78)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 161 lines diff across 5 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.66 · 5 substantive comment(s)
0.66
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
77%
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.304
Real PR Conversation Timeline
11 items
cmcantalupo cmcantalupo commented on Jun 09, 2026 14:41 UTC
Contributor

Thanks for the fix! One suggestion: since downstream consumers (Prometheus exporters, Kepler) select on the mon_group directory name, could we also canonicalize to the dashed form so the directory name is always predictable? Here's a commit on top of yours: https://github.com/cmcantalupo/nri-plugins/tree/canonicalize-on-674

fmuyassarov fmuyassarov commented on Jun 09, 2026 17:15 UTC
Author

Thanks for the fix! One suggestion: since downstream consumers (Prometheus exporters, Kepler) select on the mon_group directory name, could we also canonicalize to the dashed form so the directory name is always predictable? Here's a commit on top of yours: https://github.com/cmcantalupo/nri-plugins/tree/canonicalize-on-674

Sure, I don't see an issue inserting dashes to non dashed UUID. Will cherry-pick your commit to my branch.

fmuyassarov fmuyassarov commented on Jun 10, 2026 20:34 UTC
Author

> Thanks for the fix! One suggestion: since downstream consumers (Prometheus exporters, Kepler) select on the mon_group directory name, could we also canonicalize to the dashed form so the directory name is always predictable? Here's a commit on top of yours: https://github.com/cmcantalupo/nri-plugins/tree/canonicalize-on-674

> Sure, I don't see an issue inserting dashes to non dashed UUID. Will cherry-pick your commit to my branch.

@cmcantalupo , I've rebased my tree now with your addition.

Copilot Copilot commented on code on Jun 12, 2026 13:53 UTC
Code Review
cmd/plugins/resctrl-mon/plugin.go:1
@@ -333,6 +344,10 @@ func (p *plugin) ensureMonGroup(podUID, containerID, rdtClass string) error {
 		return fmt.Errorf("invalid pod UID %q", podUID)
 	}
 
+	// Canonicalize to standard dashed UUID format so the mon_group
+	// directory name is always consistent regardless of runtime.
+	podUID = canonicalizePodUID(podUID)
+

The new compact-UID support (32-char hex) is exercised in resctrl unit tests, but there are no plugin-level tests covering the end-to-end behavior where a compact pod UID is canonicalized and used for state lookups in ensureMonGroup/StartContainer/StopContainer. This makes it easy for future refactors to break state key consistency without failing tests.

Copilot Copilot commented on code on Jun 12, 2026 13:53 UTC
Code Review
cmd/plugins/resctrl-mon/resctrl_test.go:1
@@ -193,15 +193,40 @@ func TestCleanOrphanedMonGroups_StaleLocation(t *testing.T) {
 }
 
 func TestLooksLikePodUID(t *testing.T) {
+	// Standard UUID format with dashes.
 	assert.True(t, looksLikePodUID("a1b2c3d4-e5f6-7890-abcd-ef1234567890"))
 	assert.True(t, looksLikePodUID("DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF"))
 	assert.True(t, looksLikePodUID("00000000-0000-0000-0000-000000000000"))
 
+	// Compact 32-char hex format without dashes.
+	assert.True(t, looksLikePodUID("9d6530de59bb553c393de789dcfc6da7"))
+	assert.True(t, looksLikePodUID("00000000000000000000000000000000"))
+	assert.True(t, looksLikePodUID("DEADBEEFDEADBEEFDEADBEEFDEADBEEF"))
+
 	assert.False(t, looksLikePodUID("short"))
 	assert.False(t, looksLikePodUID("not-a-uuid-at-all-nope-notthisone!"))
 	assert.False(t, looksLikePodUID("a1b2c3d4-e5f6-7890-abcd-ef123456789"))   // too short last segment
 	assert.False(t, looksLikePodUID("g1b2c3d4-e5f6-7890-abcd-ef1234567890"))  // 'g' is not hex
 	assert.False(t, looksLikePodUID("a1b2c3d4-e5f6-7890-abcd-ef1234567890x")) // too long
+	assert.False(t, looksLikePodUID("9d6530de59bb553c393de789dcfc6da!"))      // invalid char in 32-char form
+}
+
+func TestCanonicalizePodUID(t *testing.T) {
+	// Already canonical (dashed) — should lowercase.
+	assert.Equal(t, "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
+		canonicalizePodUID("A1B2C3D4-E5F6-7890-ABCD-EF1234567890"))
+
+	// Already canonical and lowercase — returned as-is.
+	assert.Equal(t, "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
+		canonicalizePodUID("a1b2c3d4-e5f6-7890-abcd-ef1234567890"))
+
+	// Compact 32-char form — should insert dashes and lowercase.
+	assert.Equal(t, "9d6530de-59bb-553c-393d-e789dcfc6da7",
+		canonicalizePodUID("9d6530de59bb553c393de789dcfc6da7"))
+
+	// Compact uppercase — should insert dashes and lowercase.
+	assert.Equal(t, "deadbeef-dead-beef-dead-beefdeadbeef",
+		canonicalizePodUID("DEADBEEFDEADBEEFDEADBEEFDEADBEEF"))
 }

cleanOrphanedMonGroups/cleanOrphanedInDir now treats compact 32-char hex directory names as pod UIDs. There should be a regression test asserting that a compact-name mon_group directory is removed as orphaned when the corresponding pod is tracked under the canonical dashed UID.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Jun 12, 2026 13:53 UTC
Reviewer

Pull request overview

This PR updates the resctrl-mon plugin to accept Kubernetes pod UIDs both in dashed UUID form and in compact 32-character hex form, and to canonicalize UIDs to a consistent dashed lowercase representation for internal state tracking and lookups. This prevents mon_group creation failures for pods whose UID is reported without dashes.

Changes:

  • Extend looksLikePodUID() to recognize both dashed UUIDs and compact 32-char hex UIDs, and introduce canonicalizePodUID() to normalize to dashed lowercase form.

  • Canonicalize pod UIDs for state lookups and mon_group handling in the plugin lifecycle (synchronize/start/stop paths).

  • Expand unit tests to cover compact UID recognition and canonicalization.
  • Reviewed changes

    Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

    | File | Description |
    | ---- | ----------- |
    | cmd/plugins/resctrl-mon/resctrl.go | Accept compact UIDs in looksLikePodUID() and canonicalize UIDs for state lookups during orphan cleanup. |
    | cmd/plugins/resctrl-mon/resctrl_test.go | Add tests for compact UID validation and UID canonicalization. |
    | cmd/plugins/resctrl-mon/plugin.go | Canonicalize pod UIDs to keep podState keys consistent across runtime UID formats. |

    ---

    💡 <a href="/containers/nri-plugins/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

    fmuyassarov fmuyassarov commented on Jun 15, 2026 06:58 UTC
    Author

    @kad can you take a look?

    cmcantalupo cmcantalupo approved these changes on Jun 15, 2026 16:27 UTC
    Approved Reviewer

    Approved these changes.

    kad kad approved these changes on Jun 15, 2026 17:14 UTC
    Approved Reviewer

    lgtm

    askervin askervin approved these changes on Jun 16, 2026 11:41 UTC
    Approved Reviewer

    LGTM

    Reviewers
    Assignees
    fmuyassarov fmuyassarov
    Labels
    risk: low confidence: 77.8% 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.3% (MEDIUM) · Higher = larger blast radius
    39.3%
    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: 77.8% · Lower = rushed or shallow review
    77.8%
    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: 8.7% · Safe to merge
    8.7%