← Back to Pull requests

memory-policy: fix policies with no nodes #832

Closed
unknown closed this pull request without merging on Oct 13, 2026 08:40 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 06:58 UTC
Author

Fix memory policies with no nodes

This fixes two bugs in the memory-policy plugin. Both are in how it resolves the nodes of a policy.

A policy without nodes crashes the plugin

nodes is optional in a policy, but the plugin reads Nodes[0], which panics when it is empty. For example, this annotation crashes the plugin on the first container it applies to:

policy.memory-policy.nri.io: |
  mode: MPOL_INTERLEAVE

The container starts anyway, with the default memory policy, and nothing reports it. When the plugin is restarted, it crashes again on the next such container.

No nodes now means allowed-mems.

MPOL_DEFAULT and MPOL_LOCAL cannot be used

The kernel refuses any nodes for these two modes (see set_mempolicy(2)). But every nodes value resolves to some nodes, and no nodes crashes the plugin. So a container with one of these modes either fails to start, because mpolset exits with invalid argument, or loses its policy.

These modes now get no nodes, and a nodes value with them is refused with an error.

Testing

  • TestToLinuxMemoryPolicyNodes, the first unit test of the plugin, covers both fixes. Without them it panics.

  • On a VM with 4 NUMA nodes, containerd v2.4.1 and injectMpolset: true, checked in the container's /proc/1/numa_maps: MPOL_INTERLEAVE with no nodes gives interleave:0-3, MPOL_LOCAL gives local and MPOL_DEFAULT gives default. MPOL_LOCAL with nodes: 0-1 is refused with memory policy mode MPOL_LOCAL takes no nodes, got "0-1". Before the fix, the first case crashed the plugin.
  • Diff: 198 lines (+148 / -50) across 2 files Reviewer: askervin Review duration: 102m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 198 lines diff across 2 files
    0.36
    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.317
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #832"
    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: 36.1% (MEDIUM) · Higher = larger blast radius
    36.1%
    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: 14.3% · Safe to merge
    14.3%