From dc5c98a9daabe0f04330f0d3c8bb199a3a01dfef Mon Sep 17 00:00:00 2001 From: Cleo Schneider Date: Wed, 11 Oct 2023 16:43:14 -0400 Subject: [PATCH] Add default retry configuration with 3 retries --- .../src/main/kotlin/ftl/client/google/GcStorage.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_runner/src/main/kotlin/ftl/client/google/GcStorage.kt b/test_runner/src/main/kotlin/ftl/client/google/GcStorage.kt index 66fb0be61b..898bb8636b 100644 --- a/test_runner/src/main/kotlin/ftl/client/google/GcStorage.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/GcStorage.kt @@ -6,6 +6,7 @@ import com.google.cloud.storage.Storage import com.google.cloud.storage.Storage.BlobListOption.pageSize import com.google.cloud.storage.Storage.BlobListOption.prefix import com.google.cloud.storage.StorageOptions +import com.google.cloud.storage.StorageRetryStrategy import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper import com.google.common.annotations.VisibleForTesting import flank.common.join @@ -23,13 +24,24 @@ import java.nio.ByteBuffer import java.nio.file.Files import java.util.concurrent.ConcurrentHashMap + object GcStorage { private val uploadCache: ConcurrentHashMap = ConcurrentHashMap() private val downloadCache: ConcurrentHashMap = ConcurrentHashMap() val storageOptions: StorageOptions by lazy { + // Set the max number of attempts to 4 (initial attempt plus 3 retries) + val retrySettings = StorageOptions.getDefaultRetrySettings() + .toBuilder() + .setMaxAttempts(4) + .setRetryDelayMultiplier(2.0) + .setTotalTimeout(org.threeten.bp.Duration.ofMinutes(3)) + .build() + val builder = StorageOptions.newBuilder() + .setStorageRetryStrategy(StorageRetryStrategy.getDefaultStorageRetryStrategy()) + .setRetrySettings(retrySettings) if (FtlConstants.useMock) builder.setHost(FtlConstants.localhost) builder.setCredentials(credential)