← Back to Pull requests

resctrl-mon: OTel telemetry via goresctrl pkg/monitor #757

Closed
unknown closed this pull request without merging on Oct 01, 2026 17:51 UTC
View on GitHub
unknown unknown commented on Aug 18, 2026 20:56 UTC
Author

Description

This PR reworks the resctrl-mon NRI plugin to manage per-pod resctrl monitoring groups (mon_groups) with goresctrl/pkg/monitor (goresctrl v0.14.0). Their counters are exported through an embedded OpenTelemetry SDK. This replaces the plugin's inline resctrl handling (resctrl.go, state.go).

Commits

1. resctrl-mon: OTel telemetry via goresctrl pkg/monitor: the plugin, its docs and the sample config.
2. resctrl-mon: Helm chart telemetry configuration: chart values, templates and README.
3. resctrl-mon: reference OTel collector and Grafana dashboards: optional assets that are applied by hand.
4. Hardening, telemetry, and coexistence updates:
- Reserving labels derived by OTLP-to-Prometheus translation and rejecting collisions.
- Ignoring dead sandboxes at sync on containerd.
- Reading RDT class from Linux.Rdt.ClosId and implementing pod-level class selection.
- Defaulting AppArmor profile to Unconfined in the Helm chart.
- Defaulting OTLP export to TLS, Prometheus PodMonitor support, and packaging cleanup.

Plugin behavior

  • Group lifetime is scoped to the pod sandbox.

  • - The group is created in PostCreateContainer.
    - The container's init PID is written in StartContainer, with PostStartContainer as a fallback.
    - The group is removed only when the pod's last sandbox is removed. Kubelet also garbage-collects older sandboxes of a still-running pod (same UID, for example after a node reboot or pause-container death), so the plugin tracks sandbox IDs per pod.
    - Container stops never release the RMID, which avoids residual-counter energy spikes when a container restarts.
  • RDT class resolution and allocation preservation:

  • - getRDTClass reads Linux.Rdt.ClosId (populated from OCI linux.intelRdt.closID by runtimes), falling back to Linux.Resources.RdtClass. (Note: upstream main has this same bug, reading only Linux.Resources.RdtClass, which CRI runtimes do not set).
    - The pod's monitoring group class is determined by the pod-level annotation rdt.resources.beta.kubernetes.io/pod (falling back to the first arriving container's class if absent).
    - Containers whose class differs from the pod's group (such as an off-class sidecar) do not have their PID assigned to the pod's mon_group, preserving their CAT/MBA allocation in their respective class.
  • Recovery. Synchronize removes groups left behind by a previous process, adopts live groups under their on-disk class, and a background reconciler retries failed removals.

  • Concurrency and configuration. NRI handlers and the reconciler are serialized by one mutex. The configuration is read once at startup; restart the plugin to change it.

  • Metrics endpoint. The endpoint is unauthenticated. Collection is cached for 1 s and in-flight requests are capped, so a scrape burst cannot drive unbounded resctrl reads. A telemetry start failure is logged and does not stop mon_group management.
  • Metric names

    Names are pinned to the UnderscoreEscapingWithSuffixes translation strategy:

  • l3_llc_occupancy_bytes

  • l3_mbm_local_bytes_total

  • l3_mbm_bytes_total

  • perf_core_energy_joules_total

  • perf_activity_farads_total
  • The metric table and label list are in docs/monitoring/resctrl-mon.md.

    With goresctrl v0.14.0, perf_activity_farads_total is in true farads. The kernel reports nanofarads, so values are 1e9 times smaller than before this bump, and the dashboards use SI-prefixed units.

    Helm chart and security configuration

  • AppArmor profile: The Helm chart defaults appArmorProfile: {type: Unconfined} (rendered as securityContext.appArmorProfile on Kubernetes ≥ 1.30, and via container.apparmor.security.beta.kubernetes.io/nri-resctrl-mon annotation on < 1.30).

  • - Cause: containerd's cri-containerd.apparmor.d and CRI-O's crio-default AppArmor profiles deny writes under /sys/fs/[^c], which silently blocks resctrl manipulation despite CAP_SYS_ADMIN while the plugin container stays Ready.
    -
    Note:* Other plugins granting resctrl capabilities (balloons, topology-aware) are likely similarly affected when RDT is enabled.
  • Telemetry configuration: Rendered via toYaml, Prometheus PodMonitor resource support, and NODE_NAME injected for the k8s.node.name label.

  • optional/ directory:

  • - Reference OTel Collector agent DaemonSet and Grafana dashboards for cluster deployment.

    Testing

  • Local: go build ./..., go vet, gofmt -l, golangci-lint, helm lint, and go test -race -count=1 ./cmd/plugins/resctrl-mon/... pass.

  • Live Integration Tests (containerd v2.3.2 and CRI-O 1.36.6 on Xeon 6 AET):

  • - Validated using the integration test suite (resctrl-mon-tests):
    - containerd: 145/145 lifecycle tests PASS.
    - CRI-O: 103/103 lifecycle tests PASS.
    - RDT class pods & sidecars: L5 and L6 PASS on both runtimes in both container creation orders (main first and sidecar first). The pod group is placed in itgold, the main PID joins, and the itbronze sidecar PID is isolated in class tasks.
    - Runtime switching (R8): Verified live transition from containerd to CRI-O and back with active workloads.
    - Node reboot (R9): Verified group reconstruction after host reboot on containerd.
    - AppArmor: Confirmed plugin runs unconfined and successfully writes resctrl groups on both runtimes.

    Known Coexistence & Runtime Limitations

  • Runtime RDT Prune: Runtimes configured with rdt_config_file call rdt.Initialize("") at startup, pruning unknown ctrl groups and empty mon_groups. Pods without running containers (Completed, in backoff) lose their mon_group, RMID, and counter continuity. Hand-made ctrl groups should not be maintained on hosts with runtime RDT management enabled.

  • containerd Pre-restart Sandbox Event Drop (Variant A): In containerd (v2.3.2 and main), internal/nri/nri.go state tracking gates StopPodSandbox and RemovePodSandbox on in-memory local.state, which syncPlugin populates only for containers, not sandboxes. Consequently, pods surviving across containerd restarts do not emit StopPodSandbox or RemovePodSandbox to NRI plugins when deleted. The plugin retains the pod's mon_group until the next plugin restart/sync. (Verified with the containerd/nri logger plugin).
  • Follow-ups (separate PRs)

  • RMID exhaustion retry loop in background reconciler.

  • Distinct error metric/signal when resctrl writes fail with EACCES.

  • An install-plugins Makefile target.

  • goresctrl log bridging.

  • OTLP endpoint validation and TLS/auth docs.

  • A values.schema.json telemetry block.

  • Strict config parsing.

  • An optional chart NetworkPolicy for the metrics port.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: marquiz Review duration: 63175m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #757"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 20.5% · Safe to merge
    20.5%