Repository navigation
cri: skip pause image pull for shim sandboxer - #13424
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CRI RunPodSandbox flow to avoid pre-pulling the pause image when the sandbox is managed by a non-podsandbox controller (e.g., shim-based sandboxers like Kata), since those controllers do not use the pause image.
Changes:
- Gate
ensurePauseImageExists()so it runs only whensandbox.Sandboxeris thepodsandboxcontroller. - Update the surrounding comment to clarify why the pause image pull is controller-specific.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1492524 to
d114ea9
Compare
90481bd to
9704986
Compare
9704986 to
9089238
Compare
| } | ||
|
|
||
| func (c *criService) maybePullPauseImage(ctx context.Context, sandboxer string, config *runtime.PodSandboxConfig, runtimeHandler string) error { | ||
| if sandboxer != string(criconfig.ModePodSandbox) { |
There was a problem hiding this comment.
Not sure how existing sandbox shims use this. Just feel like it's breaking change.
There was a problem hiding this comment.
Thx @fuweid. maybe we will have such concerns. If so, an alternative choice is adding a knob which is responsible for explicitly enabling it in containerd runtimeclass.
The code looks like as:
type Runtime struct {
...
DisablePullPauseImage bool `toml:"disable_pull_pause_image" json:"disablePullPauseImage"`
...
}
if !ociRuntime.DisablePullPauseImage {
if err := c.ensurePauseImageExists(ctx, r.GetConfig(), r.GetRuntimeHandler()); err != nil {
return nil, err
}
}The DisablePullPauseImage is set default false and it will skip the pause image handling logic only when it's set with true in config.toml .
With this design, it will not break the original pause image handling logic, it will just skip when you set disable_pull_pause_image = true in config.toml. WDYT ?
There was a problem hiding this comment.
Hey @mxpv Looking forward to your feedback. Thx.
There was a problem hiding this comment.
Agree to the idea of improving the sandboxer config by providing one..
Maybe something like this:
[plugins.'io.containerd.sandboxer.v1.podsandbox']
disable_ensuring_pod_image = false # if set to true the sandbox config does not require the sandbox container image to be ensured
pod_image = `` # if specified (non-nil) overloads the default sandbox container image
[plugins.'io.containerd.sandboxer.v1.anothersandbox']
disable_ensuring_pod_image = true # if set to true the sandbox config does not require the sandbox container image to be ensured
possibly a sandboxer config .. right now podsandbox has some config/setup expectations and obviously those won't always match up.
There was a problem hiding this comment.
The long term desire is to offload pause container image pulling down to shim level (CRI calls Controller, implementation does the pull), so strictly speaking the originally proposed approach in this PR is more aligned (if not podsandbox, skip pull). Originally this code lived in podsandbox/ package, but moved back to CRI because of refactoring complexity (more context here #12849). Also I don't think having pause container outside of podsandbox containers brings a lot to the table. That said, I agree this is going to be a behavior change and if we want to be strict about it, then the config flag is the way.
There was a problem hiding this comment.
Thx @mxpv for your professional advice and IMHO, I agree without breaking changes. I will update the code changes as like the snipt showed.
There was a problem hiding this comment.
Agree to the idea of improving the sandboxer config by providing one..
Maybe something like this:
[plugins.'io.containerd.sandboxer.v1.podsandbox'] disable_ensuring_pod_image = false # if set to true the sandbox config does not require the sandbox container image to be ensured pod_image = `` # if specified (non-nil) overloads the default sandbox container image [plugins.'io.containerd.sandboxer.v1.anothersandbox'] disable_ensuring_pod_image = true # if set to true the sandbox config does not require the sandbox container image to be ensuredpossibly a sandboxer config .. right now
podsandboxhas some config/setup expectations and obviously those won't always match up.
Thx @mikebrow for your advice.
9089238 to
4ec99aa
Compare
|
It looks good but please squash your commits into one. Thanks |
4ec99aa to
1f82f69
Compare
1f82f69 to
93fa5b4
Compare
93fa5b4 to
1d7ca38
Compare
1d7ca38 to
85cd3d1
Compare
The RunPodSandbox unconditionally pre-pulls the pause container image via ensurePauseImageExists() before starting any sandbox. However, only the "podsandbox" controller actually uses the pause image to create a pause container holding namespaces. Shim-based sandbox controllers (e.g. Kata Containers) manage the sandbox lifecycle entirely at the shim level and never reference the pause image. Add a DisablePauseImagePull flag to the Runtime config that gates ensurePauseImageExists(). When a sandboxer is not "podsandbox", the flag skips the unnecessary pre-pull, avoiding wasted network/storage overhead and reducing sandbox startup latency. The long-term direction is to offload image pulling entirely to the controller implementation (shim level); this flag is an incremental step toward that goal without introducing a breaking behavior change. Also add unit tests to verify that ensurePauseImageExists is only invoked for the "podsandbox" sandboxer and correctly skipped otherwise. Signed-off-by: Alex Lyn <[email protected]>
85cd3d1 to
8f7c7fb
Compare
Background
When using the Sandbox API with sandboxer = "shim" (e.g. Kata Containers), ensurePauseImageExists()
unconditionally pulls the pause image even though the shim controller never uses it. This PR skips the pull for
non-podsandbox sandboxers.
Solution
Gate the ensurePauseImageExists() call on sandbox.Sandboxer == "podsandbox":
And the containerd config.toml with the disable_pull_pause_image looks like as below: