Skip to content

Commit a6c58b8

Browse files
authored
Merge pull request #37400 from gsmet/quay-reliability
Improve reliability when downloading builder images from Quay.io
2 parents ff0dfe2 + 4be6bb2 commit a6c58b8

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-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
}

integration-tests/pom.xml

+11
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,17 @@
471471
</plugins>
472472
</build>
473473
</profile>
474+
<profile>
475+
<id>native-ci</id>
476+
<activation>
477+
<property>
478+
<name>env.CI</name>
479+
</property>
480+
</activation>
481+
<properties>
482+
<quarkus.native.builder-image.pull>missing</quarkus.native.builder-image.pull>
483+
</properties>
484+
</profile>
474485

475486
<!-- "unbind" all default executions that make no sense for (most) integration-tests -->
476487
<profile>

0 commit comments

Comments
 (0)