Skip to content

Commit 4be6bb2

Browse files
committed
Retry downloading the builder image once after 5 seconds
Might help with the current Quay.io reliability that we have, be it due to GitHub Actions or Quay.io network issues.
1 parent 92b51f3 commit 4be6bb2

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildContainerRunner.java

+30-13
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public void setup(boolean processInheritIODisabled) {
4949
// will appear to block and no output will be shown
5050
String effectiveBuilderImage = nativeConfig.builderImage().getEffectiveImage();
5151
var builderImagePull = nativeConfig.builderImage().pull();
52-
log.infof("Checking status of builder image '%s'", effectiveBuilderImage);
5352
if (builderImagePull != NativeConfig.ImagePullStrategy.ALWAYS) {
53+
log.infof("Checking status of builder image '%s'", effectiveBuilderImage);
5454
Process imageInspectProcess = null;
5555
try {
5656
final ProcessBuilder pb = new ProcessBuilder(
@@ -82,20 +82,37 @@ public void setup(boolean processInheritIODisabled) {
8282
}
8383
}
8484
}
85-
Process pullProcess = null;
85+
8686
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);
9895
}
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();
99116
}
100117
}
101118
}

0 commit comments

Comments
 (0)