Skip to content
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

Implement WithImagePullPolicy #606

Closed
wants to merge 7 commits into from
Closed

Implement WithImagePullPolicy #606

wants to merge 7 commits into from

Conversation

BenasB
Copy link
Contributor

@BenasB BenasB commented Oct 6, 2022

Trying to implement WithImagePullPolicy mentioned in #601. I tried to keep similar functionality to the Java counterpart where you can write a custom policy depending on the information about the cached image (e. g. policy that pulls the image if the currently cached image's Created property is 3 days old). Of course there's still the presets PullPolicy.Never, PullPolicy.Missing (default) and PullPolicy.Always like with docker run argument --pull.

I am not sure how I should proceed with tests – ideally I would want to for example test if PullPolicy.Never is working, so I would need to somehow delete the image if it's cached/pulled, but I am not sure how to do that, since I can't access the Docker.DotNet client underneath. Any suggestions appreciated.

How is this looking @HofmeisterAn ?

@BenasB BenasB marked this pull request as draft October 6, 2022 19:47
Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

👏 thanks for your contribution. PR looks good. I have just one question below.

I am not sure how I should proceed with tests – ideally I would want to for example test if PullPolicy.Never is working

You can try to pull an image we do not use, like alpine:edge. StartAsync will thrown an exception that it could not find the image.

@BenasB
Copy link
Contributor Author

BenasB commented Oct 7, 2022

Thanks for the suggestion, yes using an image we don't use would make sense for PullPolicy.Never, but not sure how to handle PullPolicy.Always - it's useful in scenarios when an image with tag latest is cached on the docker client, but there's a new version of the latest tag in the registry and you want to always check if your cached version is up to date with the version in the registry.

@HofmeisterAn
Copy link
Collaborator

Thanks for the suggestion, yes using an image we don't use would make sense for PullPolicy.Never, but not sure how to handle PullPolicy.Always - it's useful in scenarios when an image with tag latest is cached on the docker client, but there's a new version of the latest tag in the registry and you want to always check if your cached version is up to date with the version in the registry.

Lets skip that for now. If CreateAsync overrides existing images we are good. I do not think PullPolicy.Always is easy to test.

@BenasB BenasB marked this pull request as ready for review October 8, 2022 18:29
@BenasB
Copy link
Contributor Author

BenasB commented Oct 8, 2022

Sorry, I only had access to my corporate PC where I can't pull public GitHub repos, so I ended up winging it in the online vscode editor 😅 Finally got the chance to fix it, should be okay now. Excuse my commit history, it's a bit all over the place.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

Excuse my commit history, it's a bit all over the place.

No worries, we squash it anyway. Thanks again for your contribution.

@HofmeisterAn
Copy link
Collaborator

c48d858, closes #601.

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.

None yet

2 participants