Apply default-image-pull-policy to agent and checkout containers#841
Closed
seemethere wants to merge 1 commit into
Closed
Apply default-image-pull-policy to agent and checkout containers#841seemethere wants to merge 1 commit into
seemethere wants to merge 1 commit into
Conversation
The `default-image-pull-policy` config option was only applied to the `copy-agent` init container and `imagecheck-*` containers. The `agent` and `checkout` containers had no `ImagePullPolicy` set, causing Kubernetes to default to `Always` for tagged (non-digest) images. This means every job pod contacts the container registry even when images are pre-cached by a DaemonSet. If DNS to the registry is unavailable (e.g. due to stale Cilium BPF conntrack entries pointing at dead CoreDNS backends), the manifest check fails and the pod enters ImagePullBackOff — despite the image being locally cached. Apply the same `cmp.Or(DefaultImagePullPolicy, defaultPullPolicyForImage)` pattern to the `agent` and `checkout` containers, matching the existing `copy-agent` behavior. When `default-image-pull-policy` is set to `IfNotPresent`, all controller-injected containers now skip the registry check if the image is cached, making job pods resilient to transient DNS/registry outages. Default behavior is unchanged: when the config is empty, tagged images still use `PullAlways` and digest-pinned images use `PullIfNotPresent`.
Contributor
|
Hi @seemethere, thanks for the PR! I think this is a reasonably good idea. When a default is configured, it should be applied. The default agent and checkout image refs should have both a non- I noticed the tests fail, so I've gone ahead and updated them in #842. |
Contributor
|
This has now been released in v0.40.0. Please let us know how it goes! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
default-image-pull-policyconfig option is currently only applied to thecopy-agentinit container andimagecheck-*containers. Theagentandcheckoutcontainers have noImagePullPolicyset, so Kubernetes defaults toAlwaysfor tagged (non-digest) images.This means every job pod contacts the container registry to verify the image manifest, even when images are pre-cached on the node (e.g. via a DaemonSet). If DNS to the registry is unavailable, the manifest check fails and the pod enters
ImagePullBackOff— despite the image being locally cached.This PR applies the same
cmp.Or(DefaultImagePullPolicy, defaultPullPolicyForImage)pattern to theagentandcheckoutcontainers, matching the existingcopy-agentbehavior.Motivation
We run ~300 nodes with an image-prepull DaemonSet that keeps the agent image cached. When a handful of nodes lost DNS resolution (due to stale Cilium BPF conntrack entries pointing at dead CoreDNS backends), every CI job landing on those nodes failed with
ImagePullBackOffeven though the image was locally available. Settingdefault-image-pull-policy: IfNotPresentfixed thecopy-agentinit container, but theagentandcheckoutcontainers still contacted the registry and failed.Changes
scheduler.go: AddImagePullPolicyto theagentcontainer (line 547)scheduler.go: AddImagePullPolicyto thecheckoutcontainer (line 1015)copy-agentcontainerBehavior
default-image-pull-policynot setcopy-agent:Always(tagged) /IfNotPresent(digest).agent/checkout:Always(K8s default)default-image-pull-policy: IfNotPresentcopy-agent:IfNotPresent.agent/checkout: stillAlwaysIfNotPresentDefault behavior is preserved. The change only takes effect when
default-image-pull-policyis explicitly configured.Test plan
default-image-pull-policy: IfNotPresentand verify job pods useIfNotPresenton all 3 containers