@@ -38,6 +38,7 @@ public static class ImageInfo {
38
38
/**
39
39
* Util method to pull images, configure behavior via dockerconfig.
40
40
*/
41
+ @ SuppressWarnings ("resource" )
41
42
public static void pullImages (DockerConfig config , String ... imageNames ) {
42
43
Set <String > imageNameSet = new HashSet <>(Arrays .asList (imageNames ));
43
44
@@ -65,7 +66,7 @@ public static void pullImages(DockerConfig config, String... imageNames) {
65
66
}
66
67
}
67
68
68
- int retriesRemaining = config . getPullRetryCount () ;
69
+ int retryCount = 0 ;
69
70
Map <String ,PullImageResultCallback > pircMap = new HashMap <>();
70
71
71
72
// pull the images still in set.
@@ -79,15 +80,15 @@ public static void pullImages(DockerConfig config, String... imageNames) {
79
80
// wait for pulls to complete.
80
81
RuntimeException lastSeen = null ;
81
82
boolean allDone = false ;
82
- while (!allDone && retriesRemaining >= 0 ){
83
+ while (!allDone && retryCount <= config . getPullRetryCount () ){
83
84
allDone = true ;
85
+ long thisWait = config .getPullTimeout ()+(retryCount *config .getPullRetryIncrease ());
84
86
for (Entry <String , PullImageResultCallback > e : pircMap .entrySet ()) {
85
87
boolean done = false ;
86
88
try {
87
89
if (e .getValue ()==null ) continue ;
88
- log .debug ("waiting on image " +e .getKey ());
89
- int extraWait = (config .getPullRetryCount () - retriesRemaining )*config .getPullRetryIncrease ();
90
- done = e .getValue ().awaitCompletion (config .getPullTimeout () + extraWait , TimeUnit .SECONDS );
90
+ log .debug ("waiting on image " +e .getKey ()+" for " +thisWait +" seconds" );
91
+ done = e .getValue ().awaitCompletion ( thisWait , TimeUnit .SECONDS );
91
92
log .debug ("success for image " +e .getKey ());
92
93
} catch (InterruptedException ie ) {
93
94
throw BuildpackException .launderThrowable (ie );
@@ -107,13 +108,13 @@ public static void pullImages(DockerConfig config, String... imageNames) {
107
108
e .setValue (null );
108
109
}
109
110
}
110
- if (retriesRemaining >0 ){
111
+ retryCount ++;
112
+ if (retryCount <=config .getPullRetryCount ()){
111
113
if (lastSeen !=null ){
112
114
log .debug ("Error during pull " +lastSeen .getMessage ());
113
115
}
114
- log .debug ("Retrying (" +retriesRemaining +") for " +pircMap .entrySet ().stream ().filter (e -> e .getValue ()!=null ).collect (Collectors .toList ()));
116
+ log .debug ("Retrying (" +retryCount +") for " +pircMap .entrySet ().stream ().filter (e -> e .getValue ()!=null ).collect (Collectors .toList ()));
115
117
}
116
- retriesRemaining -=1 ;
117
118
}
118
119
119
120
if (lastSeen !=null && !allDone ){
0 commit comments