Skip to content

Conversation

@rnorth
Copy link
Member

@rnorth rnorth commented Aug 28, 2020

Another small mitigation for #3099: so that users have better visibility over number of images pulled during builds.

Produces an output like:

13:17:07.689 INFO  org.testcontainers.utility.ImagePullCountLogger - Testcontainers pulled the following images during execution:
    postgis/postgis:12-3.0
    postgres:10-alpine
    postgres:9.6.12
    postgres:9.6.8

Conversely if no images have been pulled, Testcontainers did not need to pull any images during execution will be logged (for avoidance of doubt).

For this change:

  • Added a singleton to keep track of images that have been pulled
  • Wired in the LoggedPullImageResultCallback mechanism to record completed pulls

I'm using String image names for this, but will raise a separate PR to refactor to use DockerImageName (that's a bit of a sprawling change).

@rnorth rnorth requested review from bsideup and kiview as code owners August 28, 2020 12:21
public synchronized static ImagePullCountLogger instance() {
if (instance == null) {
instance = new ImagePullCountLogger();
Runtime.getRuntime().addShutdownHook(new Thread(instance::logStatistics));
Copy link
Member Author

Choose a reason for hiding this comment

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

Using a JVM shutdown hook. This is not the most iron-clad way, but as this logging is informational and not required I believe it's sufficient.

@rnorth rnorth marked this pull request as draft August 28, 2020 12:26
@rnorth rnorth force-pushed the image-pull-summary-log branch 2 times, most recently from c070a9d to 2c95200 Compare August 29, 2020 08:07
@rnorth rnorth marked this pull request as ready for review August 29, 2020 08:08
@stale
Copy link

stale bot commented Jan 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Jan 24, 2021
@rnorth rnorth removed the stale label Jun 24, 2021
@eddumelendez eddumelendez requested a review from a team November 19, 2024 22:04
@rnorth
Copy link
Member Author

rnorth commented Jul 14, 2025

I think for the sake of tidiness I should close this now.

@rnorth rnorth closed this Jul 14, 2025
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