From 1f7d2790983ee5be0eb3e8b5dfee9f355401e5f5 Mon Sep 17 00:00:00 2001 From: dmilligan Date: Fri, 24 Jul 2026 16:01:28 +0100 Subject: [PATCH 1/9] Added logging in increments --- docker-versions-maven-plugin-usage/pom.xml | 10 ++++-- .../docker/client/DockerRestClient.java | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/docker-versions-maven-plugin-usage/pom.xml b/docker-versions-maven-plugin-usage/pom.xml index 6b41744..d8fe1ec 100644 --- a/docker-versions-maven-plugin-usage/pom.xml +++ b/docker-versions-maven-plugin-usage/pom.xml @@ -70,8 +70,14 @@ 3-management - cafapi/opensuse-jre8 - 3.9.3 + cafapi/opensuse-jre21 + 7.0.2 + sha256:d1b8c3467a16cab3aa81e35a3db364f8d94f7d328b53f5aa8dd5b0059ea274b2 + + + + ${dockerHubPublic}/ibmcom/db2 + 11.5.0.0 diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index 81e1466..996aa4b 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -22,6 +22,7 @@ import com.github.dockerjava.api.command.PullImageResultCallback; import com.github.dockerjava.api.exception.NotFoundException; import com.github.dockerjava.api.model.AuthConfig; +import com.github.dockerjava.api.model.PullResponseItem; import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.DockerClientImpl; @@ -32,7 +33,9 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; @@ -102,11 +105,40 @@ public boolean pullImage( } final PullImageResultCallback callback = new PullImageResultCallback() { + + final Map currentBytes = new ConcurrentHashMap<>(); + final Map totalBytes = new ConcurrentHashMap<>(); + int pullPercentage = 0; + @Override public void onError(final Throwable throwable) { LOGGER.error("Error pulling image {}:{} ", repository, tag, throwable); super.onError(throwable); } + + @Override + public void onNext(final PullResponseItem item) { + super.onNext(item); + + if (item.getId() != null && item.getProgressDetail() != null) { + currentBytes.put(item.getId(), + Optional.ofNullable(item.getProgressDetail().getCurrent()).orElse(0L)); + + totalBytes.put(item.getId(), + Optional.ofNullable(item.getProgressDetail().getTotal()).orElse(0L)); + + long current = currentBytes.values().stream().mapToLong(Long::longValue).sum(); + long total = totalBytes.values().stream().mapToLong(Long::longValue).sum(); + if (total > 0) { + int percent = (int) Math.round(current * 100.0 / total); + int progress = (percent / 10) * 10; + if (progress > pullPercentage) { + pullPercentage = progress; + LOGGER.info("Image pull progress: {}%", progress); + } + } + } + } }; return pullCommand From b6c4f63bfafd464d0d07afc1065d509087345b0e Mon Sep 17 00:00:00 2001 From: dmilligan Date: Tue, 28 Jul 2026 14:56:28 +0100 Subject: [PATCH 2/9] Updated logging, removed pull timeout --- docker-versions-maven-plugin-usage/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-versions-maven-plugin-usage/pom.xml b/docker-versions-maven-plugin-usage/pom.xml index d8fe1ec..23a6c28 100644 --- a/docker-versions-maven-plugin-usage/pom.xml +++ b/docker-versions-maven-plugin-usage/pom.xml @@ -77,7 +77,7 @@ ${dockerHubPublic}/ibmcom/db2 - 11.5.0.0 + 11.5.8.0 From 0498b4ef3f5019f52ccd22c80cda5554e776e030 Mon Sep 17 00:00:00 2001 From: dmilligan Date: Tue, 28 Jul 2026 14:57:12 +0100 Subject: [PATCH 3/9] formatting --- .../docker/client/DockerRestClient.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index 996aa4b..93d6fd0 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -17,6 +17,7 @@ import com.github.cafapi.docker_versions.plugins.HttpConfiguration; import com.github.dockerjava.api.DockerClient; +import com.github.dockerjava.api.async.ResultCallback; import com.github.dockerjava.api.command.InspectImageResponse; import com.github.dockerjava.api.command.PullImageCmd; import com.github.dockerjava.api.command.PullImageResultCallback; @@ -35,6 +36,7 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -47,6 +49,7 @@ public final class DockerRestClient { private static final Logger LOGGER = LoggerFactory.getLogger(DockerRestClient.class); + // DDD remove downloadImageTimeout and associated cfg if not using private final long downloadImageTimeout; private final DockerClient dockerClient; @@ -91,7 +94,7 @@ public Optional findImage(final String imageName) } } - public boolean pullImage( + public PullImageCmd pullImage( final String repository, final String tag, final AuthConfig authConfig @@ -108,43 +111,45 @@ public boolean pullImage( final Map currentBytes = new ConcurrentHashMap<>(); final Map totalBytes = new ConcurrentHashMap<>(); + final Set countedLayers = ConcurrentHashMap.newKeySet(); + volatile long aggregateTotal = 0L; int pullPercentage = 0; - @Override - public void onError(final Throwable throwable) { - LOGGER.error("Error pulling image {}:{} ", repository, tag, throwable); - super.onError(throwable); - } - @Override public void onNext(final PullResponseItem item) { super.onNext(item); if (item.getId() != null && item.getProgressDetail() != null) { - currentBytes.put(item.getId(), - Optional.ofNullable(item.getProgressDetail().getCurrent()).orElse(0L)); + final Long layerCurrent = Optional.ofNullable(item.getProgressDetail().getCurrent()).orElse(0L); + final Long layerTotal = Optional.ofNullable(item.getProgressDetail().getTotal()).orElse(0L); - totalBytes.put(item.getId(), - Optional.ofNullable(item.getProgressDetail().getTotal()).orElse(0L)); + currentBytes.put(item.getId(), layerCurrent); + totalBytes.put(item.getId(), layerTotal); + + // Add to aggregate total only on first progress for this layer + if (layerTotal > 0 && countedLayers.add(item.getId())) { + aggregateTotal += layerTotal; + } - long current = currentBytes.values().stream().mapToLong(Long::longValue).sum(); - long total = totalBytes.values().stream().mapToLong(Long::longValue).sum(); - if (total > 0) { - int percent = (int) Math.round(current * 100.0 / total); - int progress = (percent / 10) * 10; + final long current = currentBytes.values().stream().mapToLong(Long::longValue).sum(); + if (aggregateTotal > 0) { + final int percent = (int) Math.round(current * 100.0 / aggregateTotal); + final int progress = (percent / 10) * 10; if (progress > pullPercentage) { pullPercentage = progress; - LOGGER.info("Image pull progress: {}%", progress); + LOGGER.info("Image pull progress: {}% of {}GB", progress, String.format("%.2f", aggregateTotal / 1_000_000_000.0)); } } } } }; - return pullCommand + pullCommand .withTag(tag) .exec(callback) - .awaitCompletion(downloadImageTimeout, TimeUnit.SECONDS); + .awaitCompletion(); + + return pullCommand; } public void tagImage( From 9a452d6e2e27de3fb8695203d5990454f52a801d Mon Sep 17 00:00:00 2001 From: dmilligan Date: Tue, 28 Jul 2026 14:59:33 +0100 Subject: [PATCH 4/9] formatting --- .../cafapi/docker_versions/docker/client/DockerRestClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index 93d6fd0..35a8676 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -148,7 +148,8 @@ public void onNext(final PullResponseItem item) { .withTag(tag) .exec(callback) .awaitCompletion(); - + + // DDD returning this is not neccessary return pullCommand; } From 1ba556bd0c22e39fd9597e3c34a406a479157283 Mon Sep 17 00:00:00 2001 From: dmilligan Date: Tue, 28 Jul 2026 15:00:13 +0100 Subject: [PATCH 5/9] formatting --- .../docker/client/DockerRestClient.java | 2 +- .../plugins/PopulateProjectRegistryMojo.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index 35a8676..c295cbf 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -149,7 +149,7 @@ public void onNext(final PullResponseItem item) { .exec(callback) .awaitCompletion(); - // DDD returning this is not neccessary + // DDD returning this is not necessary return pullCommand; } diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java index df5a19c..64773c5 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java @@ -20,10 +20,14 @@ import com.github.cafapi.docker_versions.docker.client.DockerRestClient; import com.github.cafapi.docker_versions.docker.client.ImageNotFoundException; import com.github.cafapi.docker_versions.docker.client.ImageTaggingException; +import com.github.dockerjava.api.async.ResultCallback; import com.github.dockerjava.api.command.InspectImageResponse; +import com.github.dockerjava.api.command.PullImageCmd; import com.github.dockerjava.api.model.AuthConfig; import java.util.List; import java.util.Optional; + +import com.github.dockerjava.api.model.PullResponseItem; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -155,17 +159,13 @@ private InspectImageResponse pullImage(final ImageMoniker imageMoniker) { final AuthConfig authConfig = AuthConfigHelper.getAuthConfig(settings, imageMoniker.getRegistry()); - final boolean imagePullCompleted = dockerClient.pullImage( + final PullImageCmd imagePullCompleted = dockerClient.pullImage( imageMoniker.getFullImageNameWithoutTag(), imageMoniker.getTag(), authConfig); final String imageName = imageMoniker.getFullImageNameWithTag(); - if (!imagePullCompleted) { - throw new ImagePullException("Image was not pulled: " + imageName); - } - LOGGER.debug("Pulled image '{}', verify that it is now present...", imageName); final Optional image = dockerClient.findImage(imageName); if (!image.isPresent()) { From 66a5969a6765a87ffca9bfd04e5a9c2966f6d8d1 Mon Sep 17 00:00:00 2001 From: dmilligan Date: Wed, 29 Jul 2026 10:42:11 +0100 Subject: [PATCH 6/9] Removed download timeout cfg entirely --- README.md | 9 ++------- docker-versions-maven-plugin-usage/pom.xml | 2 +- .../docker/client/DockerRestClient.java | 10 ++-------- .../plugins/HttpConfiguration.java | 19 ++++++++----------- .../plugins/PopulateProjectRegistryMojo.java | 5 +---- release-notes-2.1.0.md | 4 ++++ 6 files changed, 18 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index df512b9..92d066a 100644 --- a/README.md +++ b/README.md @@ -296,8 +296,7 @@ Http connection timeout can be set in the plugin configuration. This configurati ``` 30 - 45 - 100 + 120 ``` @@ -397,11 +396,7 @@ The following configuration options can be set via environment variables. RESPONSE_TIMEOUT_SECONDS - Determines the timeout until arrival of a response from the DOCKER_HOST, default is 45s. - - - DOWNLOAD_IMAGE_TIMEOUT_SECONDS - Determines the timeout for an image pull to be completed, default is 300s. + Determines the timeout until arrival of a response from the DOCKER_HOST, default is 120s. diff --git a/docker-versions-maven-plugin-usage/pom.xml b/docker-versions-maven-plugin-usage/pom.xml index 23a6c28..2de5104 100644 --- a/docker-versions-maven-plugin-usage/pom.xml +++ b/docker-versions-maven-plugin-usage/pom.xml @@ -74,7 +74,7 @@ 7.0.2 sha256:d1b8c3467a16cab3aa81e35a3db364f8d94f7d328b53f5aa8dd5b0059ea274b2 - + ${dockerHubPublic}/ibmcom/db2 11.5.8.0 diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index c295cbf..b808ea0 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -49,8 +49,6 @@ public final class DockerRestClient { private static final Logger LOGGER = LoggerFactory.getLogger(DockerRestClient.class); - // DDD remove downloadImageTimeout and associated cfg if not using - private final long downloadImageTimeout; private final DockerClient dockerClient; public DockerRestClient(final HttpConfiguration httpConfiguration, final String dockerHost) @@ -77,7 +75,6 @@ public DockerRestClient(final HttpConfiguration httpConfiguration, final String .responseTimeout(Duration.ofSeconds(httpConfig.getResponseTimout())) .build(); - this.downloadImageTimeout = httpConfig.getDownloadImageTimout(); this.dockerClient = DockerClientImpl.getInstance(config, httpClient); } @@ -94,7 +91,7 @@ public Optional findImage(final String imageName) } } - public PullImageCmd pullImage( + public void pullImage( final String repository, final String tag, final AuthConfig authConfig @@ -137,7 +134,7 @@ public void onNext(final PullResponseItem item) { final int progress = (percent / 10) * 10; if (progress > pullPercentage) { pullPercentage = progress; - LOGGER.info("Image pull progress: {}% of {}GB", progress, String.format("%.2f", aggregateTotal / 1_000_000_000.0)); + LOGGER.info("Image pull progress: {}% of {}GB", progress, String.format("%.2f", (aggregateTotal / 1_000_000_000.0))); } } } @@ -148,9 +145,6 @@ public void onNext(final PullResponseItem item) { .withTag(tag) .exec(callback) .awaitCompletion(); - - // DDD returning this is not necessary - return pullCommand; } public void tagImage( diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java index ab4cd62..8902f5a 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java @@ -20,8 +20,7 @@ public final class HttpConfiguration { private static final int CONNECTION_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("CONNECTION_TIMEOUT_SECONDS", "30"); - private static final int RESPONSE_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("RESPONSE_TIMEOUT_SECONDS", "45"); - private static final long DOWNLOAD_IMAGE_TIMEOUT_SECONDS = getLongPropertyOrEnvVar("DOWNLOAD_IMAGE_TIMEOUT_SECONDS", "300"); + private static final int RESPONSE_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("RESPONSE_TIMEOUT_SECONDS", "120"); @Parameter private int connectionTimout = CONNECTION_TIMEOUT_SECONDS; @@ -30,7 +29,7 @@ public final class HttpConfiguration private int responseTimout = RESPONSE_TIMEOUT_SECONDS; @Parameter() - private long downloadImageTimout = DOWNLOAD_IMAGE_TIMEOUT_SECONDS; + private long downloadImageTimout = -1; public int getConnectionTimout() { @@ -42,6 +41,11 @@ public int getResponseTimout() return responseTimout; } + /** + * @deprecated No longer used, kept only for backward compatibility with existing Maven configs. + */ + @Deprecated + @SuppressWarnings("unused") public long getDownloadImageTimout() { return downloadImageTimout; @@ -52,8 +56,7 @@ public String toString() { return "HttpConfiguration [ " + "connectionTimout=" + connectionTimout + "s, " - + "responseTimout=" + responseTimout + "s, " - + "downloadImageTimout=" + downloadImageTimout + "s ]"; + + "responseTimout=" + responseTimout + "s"; } private static int getIntPropertyOrEnvVar(final String key, final String defaultValue) @@ -62,12 +65,6 @@ private static int getIntPropertyOrEnvVar(final String key, final String default return Integer.parseInt(propertyValue); } - private static long getLongPropertyOrEnvVar(final String key, final String defaultValue) - { - final String propertyValue = getPropertyOrEnvVar(key, defaultValue); - return Long.parseLong(propertyValue); - } - private static String getPropertyOrEnvVar(final String key, final String defaultValue) { final String propertyValue = System.getProperty(key); diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java index 64773c5..43414de 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java @@ -20,14 +20,11 @@ import com.github.cafapi.docker_versions.docker.client.DockerRestClient; import com.github.cafapi.docker_versions.docker.client.ImageNotFoundException; import com.github.cafapi.docker_versions.docker.client.ImageTaggingException; -import com.github.dockerjava.api.async.ResultCallback; import com.github.dockerjava.api.command.InspectImageResponse; -import com.github.dockerjava.api.command.PullImageCmd; import com.github.dockerjava.api.model.AuthConfig; import java.util.List; import java.util.Optional; -import com.github.dockerjava.api.model.PullResponseItem; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -159,7 +156,7 @@ private InspectImageResponse pullImage(final ImageMoniker imageMoniker) { final AuthConfig authConfig = AuthConfigHelper.getAuthConfig(settings, imageMoniker.getRegistry()); - final PullImageCmd imagePullCompleted = dockerClient.pullImage( + dockerClient.pullImage( imageMoniker.getFullImageNameWithoutTag(), imageMoniker.getTag(), authConfig); diff --git a/release-notes-2.1.0.md b/release-notes-2.1.0.md index ac41e1d..e2d17b1 100644 --- a/release-notes-2.1.0.md +++ b/release-notes-2.1.0.md @@ -3,6 +3,10 @@ #### Version Number ${version-number} +#### Breaking Changes +- **D1200007**: Image downloads are no longer timed out, the downloadImageTimout property and the associated +DOWNLOAD_IMAGE_TIMEOUT_SECONDS env var are no longer used. + #### New Features - **US984062**: Added a new `skipPull` config param to skip pulling an image before retagging it. This could be used when working with developer images. From 18edf1203e427bf821b9dccfc49309b0ad412e07 Mon Sep 17 00:00:00 2001 From: dmilligan Date: Thu, 30 Jul 2026 15:24:17 +0100 Subject: [PATCH 7/9] Logging completed --- README.md | 2 +- docker-versions-maven-plugin-usage/pom.xml | 5 - docker-versions-maven-plugin/pom.xml | 8 ++ .../docker/client/DockerRestClient.java | 92 ++++++++++++++----- .../plugins/HttpConfiguration.java | 15 +-- release-notes-2.1.0.md | 6 +- 6 files changed, 83 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 92d066a..fcc9f8b 100644 --- a/README.md +++ b/README.md @@ -396,7 +396,7 @@ The following configuration options can be set via environment variables. RESPONSE_TIMEOUT_SECONDS - Determines the timeout until arrival of a response from the DOCKER_HOST, default is 120s. + Determines the timeout until arrival of a response from the DOCKER_HOST, default is 300s. diff --git a/docker-versions-maven-plugin-usage/pom.xml b/docker-versions-maven-plugin-usage/pom.xml index 2de5104..c0ec0d8 100644 --- a/docker-versions-maven-plugin-usage/pom.xml +++ b/docker-versions-maven-plugin-usage/pom.xml @@ -74,11 +74,6 @@ 7.0.2 sha256:d1b8c3467a16cab3aa81e35a3db364f8d94f7d328b53f5aa8dd5b0059ea274b2 - - - ${dockerHubPublic}/ibmcom/db2 - 11.5.8.0 - diff --git a/docker-versions-maven-plugin/pom.xml b/docker-versions-maven-plugin/pom.xml index 99a0bb2..cdf9215 100644 --- a/docker-versions-maven-plugin/pom.xml +++ b/docker-versions-maven-plugin/pom.xml @@ -220,6 +220,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 9 + 9 + + diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java index b808ea0..5645ee8 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/docker/client/DockerRestClient.java @@ -17,13 +17,13 @@ import com.github.cafapi.docker_versions.plugins.HttpConfiguration; import com.github.dockerjava.api.DockerClient; -import com.github.dockerjava.api.async.ResultCallback; import com.github.dockerjava.api.command.InspectImageResponse; import com.github.dockerjava.api.command.PullImageCmd; import com.github.dockerjava.api.command.PullImageResultCallback; import com.github.dockerjava.api.exception.NotFoundException; import com.github.dockerjava.api.model.AuthConfig; import com.github.dockerjava.api.model.PullResponseItem; +import com.github.dockerjava.api.model.ResponseItem; import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.DockerClientImpl; @@ -38,7 +38,8 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.SystemUtils; @@ -106,39 +107,84 @@ public void pullImage( final PullImageResultCallback callback = new PullImageResultCallback() { - final Map currentBytes = new ConcurrentHashMap<>(); - final Map totalBytes = new ConcurrentHashMap<>(); - final Set countedLayers = ConcurrentHashMap.newKeySet(); - volatile long aggregateTotal = 0L; - int pullPercentage = 0; + private static final double ONE_GB = 1_000_000_000.0; + private static final double ONE_MB = 1_000_000.0; + private final Map layerBytes = new ConcurrentHashMap<>(); + private final Map totalBytes = new ConcurrentHashMap<>(); + private final Set countedLayers = ConcurrentHashMap.newKeySet(); + private final Map lastStatusByLayer = new ConcurrentHashMap<>(); + private final AtomicLong knownTotalBytesExpected = new AtomicLong(0L); + private final AtomicInteger pullPercentage = new AtomicInteger(0); + + @Override + public void onError(final Throwable throwable) + { + LOGGER.error("Error pulling image {}:{} ", repository, tag, throwable); + super.onError(throwable); + } @Override public void onNext(final PullResponseItem item) { super.onNext(item); if (item.getId() != null && item.getProgressDetail() != null) { - final Long layerCurrent = Optional.ofNullable(item.getProgressDetail().getCurrent()).orElse(0L); - final Long layerTotal = Optional.ofNullable(item.getProgressDetail().getTotal()).orElse(0L); - - currentBytes.put(item.getId(), layerCurrent); - totalBytes.put(item.getId(), layerTotal); + final String layerId = item.getId(); + final ResponseItem.ProgressDetail progressDetail = item.getProgressDetail(); + final String status = item.getStatus(); + final String previous = lastStatusByLayer.get(layerId); + lastStatusByLayer.put(layerId, status); + final Long layerCurrent = Optional.ofNullable(progressDetail.getCurrent()).orElse(0L); + final Long layerTotal = Optional.ofNullable(progressDetail.getTotal()).orElse(0L); + + if ("Extracting".equalsIgnoreCase(status)) { + final long pulledBytes = totalBytes.getOrDefault(layerId, 0L); + if (!"Extracting".equalsIgnoreCase(previous)) { + LOGGER.info("Extracting Layer {} ({})", layerId, stringifyBytes(pulledBytes)); + } + return; + } else if ("Downloading".equalsIgnoreCase(status)) { + if (layerCurrent > 0) { + layerBytes.put(layerId, layerCurrent); + } - // Add to aggregate total only on first progress for this layer - if (layerTotal > 0 && countedLayers.add(item.getId())) { - aggregateTotal += layerTotal; - } + // Add to aggregate total only on first progress for this layer + if (layerTotal > 0 && countedLayers.add(layerId)) { + LOGGER.info("Pulling Layer {} ({})", layerId, stringifyBytes(layerTotal)); + totalBytes.put(layerId, layerTotal); + knownTotalBytesExpected.addAndGet(layerTotal); + // If a new layer is received pull percentage is now invalid. + pullPercentage.set(0); + } - final long current = currentBytes.values().stream().mapToLong(Long::longValue).sum(); - if (aggregateTotal > 0) { - final int percent = (int) Math.round(current * 100.0 / aggregateTotal); - final int progress = (percent / 10) * 10; - if (progress > pullPercentage) { - pullPercentage = progress; - LOGGER.info("Image pull progress: {}% of {}GB", progress, String.format("%.2f", (aggregateTotal / 1_000_000_000.0))); + final long bytesDownloaded = layerBytes.values().stream().mapToLong(Long::longValue).sum(); + if (knownTotalBytesExpected.get() > 0) { + final int percent = (int) Math.round(bytesDownloaded * 100.0 / knownTotalBytesExpected.get()); + final int progress = (percent / 10) * 10; + if (LOGGER.isInfoEnabled() && progress > pullPercentage.get()) { + pullPercentage.set(progress); + LOGGER.info("Pulling layer {} ({}) {}% of {} layer{} completed, {} of {}", + layerId, + stringifyBytes(totalBytes.get(layerId)), + progress, + countedLayers.size(), + (countedLayers.size() > 1)?"s":"", + stringifyBytes(bytesDownloaded), + stringifyBytes(knownTotalBytesExpected.get())); + } } } } } + + private String stringifyBytes(final long bytes) + { + if (bytes >= ONE_GB) { + return String.format("%.2fGB", (bytes / ONE_GB)); + } else if (bytes >= ONE_MB) { + return String.format("%.2fMB", (bytes / ONE_MB)); + } + return bytes + "bytes"; + } }; pullCommand diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java index 8902f5a..de2321e 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/HttpConfiguration.java @@ -20,7 +20,7 @@ public final class HttpConfiguration { private static final int CONNECTION_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("CONNECTION_TIMEOUT_SECONDS", "30"); - private static final int RESPONSE_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("RESPONSE_TIMEOUT_SECONDS", "120"); + private static final int RESPONSE_TIMEOUT_SECONDS = getIntPropertyOrEnvVar("RESPONSE_TIMEOUT_SECONDS", "300"); @Parameter private int connectionTimout = CONNECTION_TIMEOUT_SECONDS; @@ -28,9 +28,6 @@ public final class HttpConfiguration @Parameter() private int responseTimout = RESPONSE_TIMEOUT_SECONDS; - @Parameter() - private long downloadImageTimout = -1; - public int getConnectionTimout() { return connectionTimout; @@ -41,16 +38,6 @@ public int getResponseTimout() return responseTimout; } - /** - * @deprecated No longer used, kept only for backward compatibility with existing Maven configs. - */ - @Deprecated - @SuppressWarnings("unused") - public long getDownloadImageTimout() - { - return downloadImageTimout; - } - @Override public String toString() { diff --git a/release-notes-2.1.0.md b/release-notes-2.1.0.md index e2d17b1..f80e466 100644 --- a/release-notes-2.1.0.md +++ b/release-notes-2.1.0.md @@ -4,8 +4,10 @@ ${version-number} #### Breaking Changes -- **D1200007**: Image downloads are no longer timed out, the downloadImageTimout property and the associated -DOWNLOAD_IMAGE_TIMEOUT_SECONDS env var are no longer used. +- **D1200007**: Changes in image pull timeouts. Image pull will only time out if no response is received from the Docker Daemon +within the configured time. + * DOWNLOAD_IMAGE_TIMEOUT_SECONDS : No longer used. + * RESPONSE_TIMEOUT_SECONDS : default increased to 300 seconds. #### New Features - **US984062**: Added a new `skipPull` config param to skip pulling an image before retagging it. This could be used when working with developer images. From a869be3ea96d5af63232c9fe942a0a699371e8ee Mon Sep 17 00:00:00 2001 From: dmilligan Date: Thu, 30 Jul 2026 15:29:23 +0100 Subject: [PATCH 8/9] Reviewed --- README.md | 2 +- docker-versions-maven-plugin/pom.xml | 8 -------- .../plugins/PopulateProjectRegistryMojo.java | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index fcc9f8b..bc999db 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,7 @@ Http connection timeout can be set in the plugin configuration. This configurati ``` 30 - 120 + 300 ``` diff --git a/docker-versions-maven-plugin/pom.xml b/docker-versions-maven-plugin/pom.xml index cdf9215..99a0bb2 100644 --- a/docker-versions-maven-plugin/pom.xml +++ b/docker-versions-maven-plugin/pom.xml @@ -220,14 +220,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 9 - 9 - - diff --git a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java index 43414de..d2d5718 100644 --- a/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java +++ b/docker-versions-maven-plugin/src/main/java/com/github/cafapi/docker_versions/plugins/PopulateProjectRegistryMojo.java @@ -24,7 +24,6 @@ import com.github.dockerjava.api.model.AuthConfig; import java.util.List; import java.util.Optional; - import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; From 0ddb2213024f083ad14c5f8f899b15e32aec6bb3 Mon Sep 17 00:00:00 2001 From: Build Machine Date: Thu, 30 Jul 2026 14:32:30 +0000 Subject: [PATCH 9/9] Update POM versions to 3.0.0-SNAPSHOT --- docker-versions-maven-plugin-usage/pom.xml | 4 ++-- docker-versions-maven-plugin/pom.xml | 2 +- pom.xml | 2 +- release-notes-2.1.0.md => release-notes-3.0.0.md | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename release-notes-2.1.0.md => release-notes-3.0.0.md (100%) diff --git a/docker-versions-maven-plugin-usage/pom.xml b/docker-versions-maven-plugin-usage/pom.xml index c0ec0d8..62f488b 100644 --- a/docker-versions-maven-plugin-usage/pom.xml +++ b/docker-versions-maven-plugin-usage/pom.xml @@ -24,7 +24,7 @@ com.github.cafapi.plugins.docker.versions docker-versions - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT docker-versions-maven-plugin-usage @@ -40,7 +40,7 @@ com.github.cafapi.plugins.docker.versions docker-versions-maven-plugin - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT populate-project-registry diff --git a/docker-versions-maven-plugin/pom.xml b/docker-versions-maven-plugin/pom.xml index 99a0bb2..2902d27 100644 --- a/docker-versions-maven-plugin/pom.xml +++ b/docker-versions-maven-plugin/pom.xml @@ -24,7 +24,7 @@ com.github.cafapi.plugins.docker.versions docker-versions - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT docker-versions-maven-plugin diff --git a/pom.xml b/pom.xml index 621bba6..95789cd 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ com.github.cafapi.plugins.docker.versions docker-versions - 2.1.0-SNAPSHOT + 3.0.0-SNAPSHOT pom docker-versions diff --git a/release-notes-2.1.0.md b/release-notes-3.0.0.md similarity index 100% rename from release-notes-2.1.0.md rename to release-notes-3.0.0.md