Skip to content

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

Open
fmuyassarov wants to merge 3 commits into
containers:mainfrom
Nordix:fix/resctrl
Open

resctrl-mon: accept pod UIDs without dashes too#674
fmuyassarov wants to merge 3 commits into
containers:mainfrom
Nordix:fix/resctrl

Conversation

@fmuyassarov

@fmuyassarov fmuyassarov commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

func looksLikePodUID(name string) bool {

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"

@cmcantalupo

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Collaborator 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

Copy link
Copy Markdown
Collaborator 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.

Rework looksLikePodUID() to accept/handle both formats of UUID. In
other words, with dashes (current expectation) and without dashes.

Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@est.tech>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/plugins/resctrl-mon/plugin.go Outdated
Comment on lines +347 to +350
// Canonicalize to standard dashed UUID format so the mon_group
// directory name is always consistent regardless of runtime.
podUID = canonicalizePodUID(podUID)

// Compact uppercase — should insert dashes and lowercase.
assert.Equal(t, "deadbeef-dead-beef-dead-beefdeadbeef",
canonicalizePodUID("DEADBEEFDEADBEEFDEADBEEFDEADBEEF"))
}
cmcantalupo and others added 2 commits June 12, 2026 17:43
Always canonicalize pod UIDs to the standard 8-4-4-4-12 lowercase
format before creating mon_group directories or performing state
lookups. Use github.com/google/uuid for parsing and canonicalization
which handles both compact (32-char) and dashed form.

Co-authored-by: Christopher M. Cantalupo <christopher.m.cantalupo@intel.com>
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@est.tech>
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@est.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants