Skip to content

Default ImagePullPolicy to IfNotPresent for all workload helpers#705

Merged
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
abays:fix/default-image-pull-policy
Jun 18, 2026
Merged

Default ImagePullPolicy to IfNotPresent for all workload helpers#705
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
abays:fix/default-image-pull-policy

Conversation

@abays

@abays abays commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

When ImagePullPolicy is not explicitly set on a container and the image tag is "latest" or unset, Kubernetes defaults the policy to Always, causing unnecessary image pulls on every pod restart. This affected ~120 container definitions across all service operators.

Add pod.SetPullPolicyDefaults() which sets PullIfNotPresent on any container that lacks an explicit policy, and call it from the Deployment, DaemonSet, StatefulSet, Job, and CronJob CreateOrPatch paths. Containers that already set an explicit policy (including PullAlways) are left unchanged.

Relates-To: https://redhat.atlassian.net/browse/OSPRH-26843

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

When ImagePullPolicy is not explicitly set on a container and the
image tag is "latest" or unset, Kubernetes defaults the policy to
Always, causing unnecessary image pulls on every pod restart. This
affected ~120 container definitions across all service operators.

Add pod.SetPullPolicyDefaults() which sets PullIfNotPresent on any
container that lacks an explicit policy, and call it from the
Deployment, DaemonSet, StatefulSet, Job, and CronJob CreateOrPatch
paths. Containers that already set an explicit policy (including
PullAlways) are left unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abays abays requested a review from stuggi June 18, 2026 13:12
Comment thread modules/common/job/job.go
var ctrlResult ctrl.Result
var err error

pod.SetPullPolicyDefaults(&j.expectedJob.Spec.Template.Spec)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might retrigger jobs if that results in the hash to change, but I guess thats ok/needed

@stuggi stuggi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@stuggi stuggi merged commit fe8e60d into openstack-k8s-operators:main Jun 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants