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

Image pull policy (#1345) #2024

Merged
merged 12 commits into from
Nov 27, 2019
Merged

Image pull policy (#1345) #2024

merged 12 commits into from
Nov 27, 2019

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Nov 1, 2019

See #1345 by @dmarkhas

Fixes #1324

* get exitcode from inspectExecCmd

* Update core/src/main/java/org/testcontainers/containers/Container.java

Co-Authored-By: dmarkhas <minimizer@gmail.com>

* Update core/src/main/java/org/testcontainers/containers/Container.java

Co-Authored-By: dmarkhas <minimizer@gmail.com>

* Update core/src/main/java/org/testcontainers/containers/Container.java

Co-Authored-By: dmarkhas <minimizer@gmail.com>

* Use Lombok's `@Value` in `ExecResult`

* Update Container.java

* Add image pull policy

* dont expose docker-java Image directly

* fixed pullingNonExistentImageFailsGracefully test

* fixed failing tests

* use OffsetDateTime instead of System.currentMillis

* use java.time.Instant

* make Wait and PullPolicy non-instantiable

* code review changes

* fixed failing tests

* use hamcreset anyOf

* fix ImagePullPolicyTest

* make ImageData an interface

*  revert ContainerCreationTest.java

* use java.time.Instant

* revert an unrelated change in ContainerLogsTest

* use java.time.Instant

* use redis instead of alpine in example

* use OptionalLong instead of Long in ImageData

* resolve conflict with master

* resolve conflict with master

* resolve conflict with master

* resolve conflict with master
@bsideup bsideup added this to the next milestone Nov 1, 2019
@bsideup bsideup self-assigned this Nov 1, 2019
@bsideup bsideup marked this pull request as ready for review November 3, 2019 15:33
@bsideup
Copy link
Member Author

bsideup commented Nov 3, 2019

Hey @dmarkhas,

Could you please take a look and tell us if this implementation will cover your use cases? Thanks!

@dmarkhas
Copy link
Contributor

dmarkhas commented Nov 4, 2019

Hey @dmarkhas,

Could you please take a look and tell us if this implementation will cover your use cases? Thanks!

@bsideup this look great :)

Logger logger = DockerLoggerFactory.getLogger(imageName.toString());

// Does our cache already know the image?
ImageData imageData = LOCAL_IMAGES_CACHE.get(imageName);
Copy link
Member

Choose a reason for hiding this comment

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

I'm half tempted to suggest having an additional boolean that can be used in line 27, e.g. something like:

if (isCached && !shouldPullCached(...

Alternatively, perhaps renaming this to cachedImageData would be equivalently clear.

return false;
}

log.trace("Should pull image: {}", imageName);
Copy link
Member

Choose a reason for hiding this comment

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

I have the feeling that we should always log, maybe at debug level, about the pull decision (including if we've decided not to pull!)

@kostapc
Copy link

kostapc commented Nov 9, 2019

Also covers case described in #2048

@bsideup bsideup requested a review from rnorth November 10, 2019 21:07
@bsideup bsideup merged commit 17d86c9 into master Nov 27, 2019
@delete-merged-branch delete-merged-branch bot deleted the image_pull_policy branch November 27, 2019 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for image pull policy
4 participants