Skip to content

Commit c527bbf

Browse files
authored
[CI] Workaround for Windows packaging tests hang on uploading artifacts (#137206)
Calculate upload timeout based on file size. This change replaces the fixed 30-minute timeout with a calculated value, to avoid buildkite-agent on Windows hanging for 30 minutes for small files.
1 parent 0a71ff4 commit c527bbf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.Arrays;
4949
import java.util.List;
5050
import java.util.Optional;
51+
import java.util.concurrent.TimeUnit;
5152

5253
import javax.inject.Inject;
5354

@@ -199,7 +200,11 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
199200
try {
200201
// we are very generious here, as the upload can take
201202
// a long time depending on its size
202-
pb.start().waitFor(30, java.util.concurrent.TimeUnit.MINUTES);
203+
long timeoutSec = calculateUploadWaitTimeoutSeconds(uploadFile);
204+
boolean completedInTime = pb.start().waitFor(timeoutSec, TimeUnit.SECONDS);
205+
if (completedInTime == false) {
206+
System.out.println("Timed out waiting for buildkite artifact upload after " + timeoutSec + " seconds");
207+
}
203208
} catch (InterruptedException e) {
204209
System.out.println("Failed to upload buildkite artifact " + e.getMessage());
205210
}
@@ -304,5 +309,14 @@ private static String calculateArchivePath(Path path, Path projectPath) {
304309
}
305310
return archivePath;
306311
}
312+
313+
private static long calculateUploadWaitTimeoutSeconds(File file) {
314+
long fileSizeBytes = file.length();
315+
long fileSizeMB = fileSizeBytes / (1024 * 1024);
316+
317+
// Allocate 4 seconds per MB (assumes ~250 KB/s upload speed)
318+
// with min 10 seconds and max 30 minutes
319+
return Math.max(10, Math.min(1800, fileSizeMB * 4));
320+
}
307321
}
308322
}

0 commit comments

Comments
 (0)