libpod: share container op code between Pause, Unpause, Kill and Cleanup #30393
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Honny1
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: