-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for specifying an image pull policy for containers #7697
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
src/Aspire.Hosting/ApplicationModel/ContainerPullPolicyAnnotation.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/ContainerPullPolicyAnnotation.cs
Outdated
Show resolved
Hide resolved
Does this mean we’ll get the pulling status separately in the ux? |
This PR won't give any pulling status updates, just allow controlling the behavior of when new images are pulled. Getting image pull progress from the Docker or Podman CLI is non-trivial as they only provide detailed breakdowns when running in a TTY environment. One thing we may want to consider is making container images a first class DCP resource so that we can control when to pull them independent of running the container that requires the image; that way we can differentiate between pulling an image and general container startup when reporting status (even if we can't give detailed progress on the image pull). |
/// <param name="builder">Builder for the container resource.</param> | ||
/// <param name="pullPolicy">The pull policy behavior for the container resource.</param> | ||
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns> | ||
public static IResourceBuilder<T> WithImagePullPolicy<T>(this IResourceBuilder<T> builder, ImagePullPolicy pullPolicy) where T : ContainerResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests we can write for this?
At a minimum at least calling this API and ensuring the annotation is there. Ideally, if we can tell what data gets sent to DCP, we could ensure the image pull policy is set correctly.
/// <summary> | ||
/// Gets or sets the image pull policy for the container resource. | ||
/// </summary> | ||
public required ImagePullPolicy ImagePullPolicy { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchdenny - do we usually have immutable annotation classes? Should this be a ctor parameter and a get-only property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 comments from me. Once those are addressed, I think this change looks good to go in.
Description
Adds a new ContainerImagePullPolicyAnnotation and WithImagePullPolicy builder API to allow configuring the container image pull policy for a given container resource. The supported pull policy settings are
Default
,Always
, andMissing
. A pull policy ofAlways
will result in the container image always being pulled when the container is run, regardless of whether a version of the image is cached locally.Missing
will only pull images if there is no cached version locally (and therefore you may not be using the latest version of the image).Default
represents the default behavior if no policy is specified. Currently that will be the default behavior for your container runtime (which is generally the same asMissing
for both Docker and Podman), however that could change in future Aspire releases.When building a new image from a Dockerfile,
Always
will also force pulling any base images as part of the build,Missing
will use the default behavior of only pulling images that aren't available locally, andDefault
will again match the runtime's default build process behavior.Example:
Fixes #7350
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):