Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add retry configuration to Google Cloud Storage client #2437

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test_runner/src/main/kotlin/ftl/client/google/GcStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,13 +24,24 @@ import java.nio.ByteBuffer
import java.nio.file.Files
import java.util.concurrent.ConcurrentHashMap


object GcStorage {

private val uploadCache: ConcurrentHashMap<String, String> = ConcurrentHashMap()
private val downloadCache: ConcurrentHashMap<String, String> = 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)

Expand Down