← Back to Pull requests

libpod: share container op code between Pause, Unpause, Kill and Cleanup #30393

Closed
unknown closed this pull request without merging on Nov 30, 2026 16:32 UTC
View on GitHub
unknown unknown commented on Nov 28, 2026 18:40 UTC
Author

Fixes #30205

Pod.Pause(), Pod.Unpause(), Pod.Kill() and Pod.Cleanup() in libpod/pod_api.go had almost the same body: take the pod lock, check that the pod is still valid, get the pod's containers, run one function per container with the parallel executor, collect the errors, and return ErrPodPartialFail if some containers failed. so this PR moves all that into one unexported helper, (*Pod).runCtrOp, and the four methods now only pass whats required and differs.

The lock and the valid check stay in each method. They pass the helper the function to run on a container (a method expression for Pause and Unpause, a closure for Kill and Cleanup), the verbs used in the debug log and the partial failure error, and the pod event to send. Cleanup passes an empty event, so it still sends none. Kill and Cleanup still call maybeStopServiceContainer() after the helper, and only when the helper returned no error, so a partial failure still returns before the service container is checked. In that case they return both the map and the error, as before, no change.

The change is only in libpod/pod_api.go (33 insertions, 109 deletions). Signatures and return values are the same, so the abi and REST callers are untouched. I also fixed the Cleanup doc comment, which said the containers were "paused" instead of "cleaned up".

I didn't touch things that look odd band and not related to this issue. Cleanup sends no pod event, and it is only called from the REST PodStop handler, which already sends one for the stop.

Testing:

  • make validatepr passes on this branch. golangci-lint reports 0 issues for every target, and the commit subject check passes.

  • test/e2e pod_pause_test.go and pod_kill_test.go pass (7 specs each) with make localintegration and with make remoteintegration.

  • I compared a build from before this change with a build from after it, using separate storage for each, on: the pod events from pod pause, unpause and kill (local and through podman-remote); the "clean up container" debug lines when podman-remote pod stop reaches Cleanup; and the service container exiting after podman pod kill on a pod created with kube play --service-container. The event output, debug lines, container and pod states, and exit codes were identical. I used kube play --network none because the default network failed with the netavark version installed here, on both builds.
  • Diff: 298 lines (+223 / -75) across 3 files Reviewer: Honny1 Review duration: 2752m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 298 lines diff across 3 files
    0.40
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #30393"
    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: 40% (MEDIUM) · Higher = larger blast radius
    40%
    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: 15.8% · Safe to merge
    15.8%