@@ -49,8 +49,8 @@ public void setup(boolean processInheritIODisabled) {
49
49
// will appear to block and no output will be shown
50
50
String effectiveBuilderImage = nativeConfig .builderImage ().getEffectiveImage ();
51
51
var builderImagePull = nativeConfig .builderImage ().pull ();
52
- log .infof ("Checking status of builder image '%s'" , effectiveBuilderImage );
53
52
if (builderImagePull != NativeConfig .ImagePullStrategy .ALWAYS ) {
53
+ log .infof ("Checking status of builder image '%s'" , effectiveBuilderImage );
54
54
Process imageInspectProcess = null ;
55
55
try {
56
56
final ProcessBuilder pb = new ProcessBuilder (
@@ -82,20 +82,37 @@ public void setup(boolean processInheritIODisabled) {
82
82
}
83
83
}
84
84
}
85
- Process pullProcess = null ;
85
+
86
86
try {
87
- final ProcessBuilder pb = new ProcessBuilder (
88
- Arrays .asList (containerRuntime .getExecutableName (), "pull" , effectiveBuilderImage ));
89
- pullProcess = ProcessUtil .launchProcess (pb , processInheritIODisabled );
90
- if (pullProcess .waitFor () != 0 ) {
91
- throw new RuntimeException ("Failed to pull builder image '" + effectiveBuilderImage + "'" );
92
- }
93
- } catch (IOException | InterruptedException e ) {
94
- throw new RuntimeException ("Failed to pull builder image '" + effectiveBuilderImage + "'" , e );
95
- } finally {
96
- if (pullProcess != null ) {
97
- pullProcess .destroy ();
87
+ log .infof ("Pulling builder image '%s'" , effectiveBuilderImage );
88
+ pull (effectiveBuilderImage , processInheritIODisabled );
89
+ } catch (Exception e ) {
90
+ log .infof ("Retrying in 5 seconds" );
91
+ try {
92
+ Thread .sleep (5_000L );
93
+ } catch (InterruptedException e1 ) {
94
+ throw new RuntimeException (e1 );
98
95
}
96
+ log .infof ("Pulling builder image '%s' (take 2)" , effectiveBuilderImage );
97
+ pull (effectiveBuilderImage , processInheritIODisabled );
98
+ }
99
+ }
100
+ }
101
+
102
+ private void pull (String effectiveBuilderImage , boolean processInheritIODisabled ) {
103
+ Process pullProcess = null ;
104
+ try {
105
+ final ProcessBuilder pb = new ProcessBuilder (
106
+ Arrays .asList (containerRuntime .getExecutableName (), "pull" , effectiveBuilderImage ));
107
+ pullProcess = ProcessUtil .launchProcess (pb , processInheritIODisabled );
108
+ if (pullProcess .waitFor () != 0 ) {
109
+ throw new RuntimeException ("Failed to pull builder image '" + effectiveBuilderImage + "'" );
110
+ }
111
+ } catch (IOException | InterruptedException e ) {
112
+ throw new RuntimeException ("Failed to pull builder image '" + effectiveBuilderImage + "'" );
113
+ } finally {
114
+ if (pullProcess != null ) {
115
+ pullProcess .destroy ();
99
116
}
100
117
}
101
118
}
0 commit comments