resctrl-mon: add NRI plugin for per-pod resctrl monitoring groups#666
Open
cmcantalupo wants to merge 2 commits intocontainers:mainfrom
Open
resctrl-mon: add NRI plugin for per-pod resctrl monitoring groups#666cmcantalupo wants to merge 2 commits intocontainers:mainfrom
cmcantalupo wants to merge 2 commits intocontainers:mainfrom
Conversation
Add nri-resctrl-mon, a standalone NRI plugin that creates per-pod resctrl monitoring groups (mon_groups) to support passive monitorning of Application Energy Telemetry (AET). The plugin uses the PostCreateContainer hook to assign container PIDs to mon_groups before exec/fork, eliminating the fork race that plagues userspace daemon approaches. RMID allocation is delegated to the kernel via mkdir/rmdir on the resctrl filesystem. Includes: - Plugin source (main.go, plugin.go, resctrl.go, state.go) - Unit tests (plugin_test.go, resctrl_test.go) - Dockerfile following nri-memory-qos pattern - Helm chart (Chart.yaml, values.yaml, templates/, schema) - Documentation (monitoring category, plugin docs, Helm docs) - Sample configuration Signed-off-by: Christopher M. Cantalupo <christopher.m.cantalupo@intel.com> Signed-off-by: Jedrzej Wasiukiewicz <jedrzej.wasiukiewicz@intel.com>
Record initial and final resctrl counter values so that consumers
(e.g. Kepler) can account for energy consumed between the last scrape
and mon_group removal, and between mon_group creation and the first
scrape.
The snapshot directory mirrors the resctrl mon_data layout:
/run/nri-resctrl-mon/<pod-uid>/
created_at
completed_at
mon_data/mon_PERF_PKG_00/
core_energy → /sys/fs/resctrl/.../core_energy
core_energy.begin
core_energy.end
On first PID write (StartContainer / PostStartContainer / Synchronize),
the plugin reads all mon_data event files and writes .begin counter
files alongside symlinks to the live resctrl event files. On the last
container stop (StopContainer), the counters are read again as .end
files. Consumers compute lifetime totals as: end - begin.
This format lets existing resctrl consumers discover and use the
snapshot data with no new parsing logic — the same cat/read operations
work on .begin/.end files as on kernel event files. If the snapshot
directory is absent, consumers fall back to direct resctrl scraping.
Completed snapshot directories are pruned after a configurable TTL
(default 5m).
New configuration keys: snapshotDir, snapshotTTL.
Signed-off-by: Christopher M. Cantalupo <christopher.m.cantalupo@intel.com>
Signed-off-by: Jedrzej Wasiukiewicz <jedrzej.wasiukiewicz@intel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add nri-resctrl-mon, a standalone NRI plugin that creates per-pod resctrl monitoring groups (
mon_groups) to support passive monitoring of Application Energy Telemetry (AET) via consumers.Motivation
Userspace daemon approaches to resctrl mon_group management suffer from a fork race: a container's first threads can execute before the daemon writes their PIDs into the mon_group's
tasksfile, causing energy attribution gaps. By using the NRIPostCreateContainerhook, this plugin assigns container PIDs to mon_groups before exec/fork, eliminating the race entirely.What's included
Commit 1: Core plugin
main.go,plugin.go,resctrl.go,state.go)plugin_test.go,resctrl_test.go)nri-memory-qospatternChart.yaml,values.yaml, templates, JSON schema)Commit 2: Counter snapshots
snapshot.go,snapshot_test.go) that mirrors the resctrlmon_datalayout at/run/nri-resctrl-mon/<pod-uid>/.begincounter files and creates symlinks to live kernel event files.endfiles, removes symlinks, writescompleted_atend − beginwith no new parsing logicsnapshotDir,snapshotTTLSnapshot directory layout
Design decisions
PostCreateContainerensures PIDs are assigned before any user code runs.mkdir/rmdiron resctrl delegates RMID lifecycle to the kernel, avoiding userspace exhaustion bugs..endfiles are written (before the mon_group directory is removed), so dangling symlinks never exist.Synchronizere-creates mon_groups for running pods on plugin restart.SYS_ADMIN+DAC_OVERRIDEonly (noprivileged: true).Testing
.begin/.endvalues and symlink cleanup.Stats