Skip to content

Commit b0e62a1

Browse files
committed
fix : Introduce pullRetries and pushRetries fields
Signed-off-by: Rohan Kumar <[email protected]>
1 parent e823b55 commit b0e62a1

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

src/main/asciidoc/inc/build/_configuration.adoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ a| Scan the archive specified in `dockerArchive` and find the actual repository
120120
| *shell*
121121
| Shell to be used for the *runCmds*. It contains *arg* elements which are defining the executable and its params.
122122

123-
| *retries*
124-
| If pulling an image is required, how often should a pull be retried before giving up. This useful for flaky registries which tend to return 500 error codes from time to time. The default is 0 which means no retry at all.
125-
126123
| *runCmds*
127124
| Commands to be run during the build process. It contains *run* elements which are passed to the shell. Whitespace is trimmed from each element and empty elements are ignored. The run commands are inserted right after the assembly and after *workdir* into the Dockerfile. This tag is not to be confused with the `<run>` section for this image which specifies the runtime behaviour when starting containers.
128125

src/main/asciidoc/inc/start/_configuration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In addition to the <<global-configuration>>, this goal supports the following gl
99
| Default pattern for naming all containers when they are created. See <<container-name, Container Names>> for details.
1010
| `docker.containerNamePattern`
1111

12-
| *retries*
12+
| *pullRetries*
1313
| If pulling an image is required, how often should a pull be retried before giving up. This useful for flaky registries which tend to return 500 error codes from time to time. The default is 0 which means no retry at all.
1414
| `docker.pull.retries`
1515

src/main/asciidoc/inc/watch/_configuration.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ below how this can be specified.
5555
| `docker.keepRunning`
5656

5757
| *keepContainer*
58-
| As for `{plugin}:stop`, if this is set to `true` (and `keepRunning` is disabled) then all container will be removed after they have been stopped. The default is `true`.
58+
| As for `{plugin}:stop`, if this is set to `true` (and `keepRunning` is disabled) then all container will be removed after they have been stopped. The default is `false`.
5959
| `docker.keepContainer`
6060

6161
| *removeVolumes*
6262
| if set to `true` will remove any volumes associated to the container as well. This option will be ignored if either `keepContainer` or `keepRunning` are `true`.
6363
| `docker.removeVolumes`
6464

65-
| *retries*
65+
| *pullRetries*
6666
| If pulling an image is required, how often should a pull be retried before giving up. This useful for flaky registries which tend to return 500 error codes from time to time. The default is 0 which means no retry at all.
6767
| `docker.pull.retries`
6868
|===

src/main/java/io/fabric8/maven/docker/AbstractDockerMojo.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ public abstract class AbstractDockerMojo extends AbstractMojo implements Context
121121
@Parameter(property = "docker.removeVolumes", defaultValue = "false")
122122
protected boolean removeVolumes;
123123

124-
@Parameter(property = "docker.pull.retries", defaultValue = "0")
124+
@Parameter(property = "docker.retries", defaultValue = "0")
125125
protected int retries;
126126

127+
@Parameter(property = "docker.pull.retries", defaultValue = "0")
128+
protected int pullRetries;
129+
130+
@Parameter(property = "docker.push.retries", defaultValue = "0")
131+
protected int pushRetries;
132+
127133
@Parameter(property = "docker.apiVersion")
128134
private String apiVersion;
129135

@@ -580,7 +586,7 @@ protected void pullImage(RegistryService registryService, ImageConfiguration ima
580586
RunImageConfiguration runConfiguration = imageConfig.getRunConfiguration();
581587
ImagePullManager pullManager = getImagePullManager(determinePullPolicy(runConfiguration), autoPull);
582588
RegistryConfig registryConfig = getRegistryConfig(pullRegistry);
583-
registryService.pullImageWithPolicy(imageName, pullManager, registryConfig, imageConfig.getBuildConfiguration(), retries);
589+
registryService.pullImageWithPolicy(imageName, pullManager, registryConfig, imageConfig.getBuildConfiguration(), pullRetries);
584590
}
585591

586592
protected boolean shouldSkipPom() {

src/main/java/io/fabric8/maven/docker/PushMojo.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ public class PushMojo extends AbstractDockerMojo {
3030
*/
3131
@Parameter(property = "docker.skip.tag", defaultValue = "false")
3232
private boolean skipTag;
33-
34-
@Parameter(property = "docker.push.retries", defaultValue = "0")
35-
private int retries;
3633

3734
/**
3835
* {@inheritDoc}

src/test/java/io/fabric8/maven/docker/access/hc/DockerAccessWithHcClientTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import static org.mockito.ArgumentMatchers.anyMap;
3838
import static org.mockito.ArgumentMatchers.anyString;
3939
import static org.mockito.ArgumentMatchers.isNull;
40+
import static org.mockito.Mockito.times;
4041

4142
@ExtendWith(MockitoExtension.class)
4243
class DockerAccessWithHcClientTest {
@@ -552,7 +553,7 @@ private void givenPostCallThrowsException() throws IOException {
552553

553554
private void thenImageWasPulled(int pushPullRetries) throws IOException {
554555
ArgumentCaptor<String> urlCapture = ArgumentCaptor.forClass(String.class);
555-
Mockito.verify(mockDelegate)
556+
Mockito.verify(mockDelegate, times(pushPullRetries))
556557
.post(urlCapture.capture(), Mockito.isNull(), Mockito.anyMap(), Mockito.any(ResponseHandler.class), Mockito.eq(HTTP_OK));
557558

558559
String postUrl = urlCapture.getValue();

0 commit comments

Comments
 (0)