resctrl-mon: accept pod UIDs without dashes too#674
Conversation
|
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>
There was a problem hiding this comment.
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 introducecanonicalizePodUID()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.
| // 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")) | ||
| } |
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>
nri-plugins/cmd/plugins/resctrl-mon/resctrl.go
Line 180 in 9b9f6c4
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 withmon_groupcreation for those pods entirely.Example log snippet before the fix:
and after