resctrl-mon: accept pod UIDs without dashes too #674
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
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.
> 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.
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.
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.
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:
looksLikePodUID() to recognize both dashed UUIDs and compact 32-char hex UIDs, and introduce canonicalizePodUID() to normalize to dashed lowercase form.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>.
@kad can you take a look?
Approved these changes.
lgtm
LGTM
cmcantalupo
fmuyassarov
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 withmon_groupcreation for those pods entirely.Example log snippet before the fix:
and after