Skip to content

Commit

Permalink
Increased the retries
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasm-ttd committed May 1, 2024
1 parent 0ea2229 commit 06314e9
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.uid2.attestation.azure;

import com.azure.core.http.policy.ExponentialBackoffOptions;
import com.azure.core.http.policy.RetryOptions;
import com.azure.identity.ManagedIdentityCredentialBuilder;
import com.azure.security.keyvault.secrets.SecretClientBuilder;
import com.google.common.base.Strings;
import com.uid2.enclave.IOperatorKeyRetriever;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Duration;

public class AzureVaultOperatorKeyRetriever implements IOperatorKeyRetriever {
private static final Logger LOGGER = LoggerFactory.getLogger(AzureVaultOperatorKeyRetriever.class);

Expand All @@ -29,10 +33,17 @@ public AzureVaultOperatorKeyRetriever(String vaultName, String secretName) {
public String retrieve() {
String vaultUrl = "https://" + this.vaultName + ".vault.azure.net";
LOGGER.info(String.format("Load OperatorKey secret (%s) from %s", this.secretName, vaultUrl));
// Use default ExponentialBackoff retry policy

ExponentialBackoffOptions exponentialBackoffOptions = new ExponentialBackoffOptions()
.setMaxRetries(10)
.setBaseDelay(Duration.ofSeconds(1))
.setMaxDelay(Duration.ofSeconds(30));
RetryOptions retryOptions = new RetryOptions(exponentialBackoffOptions);

var secretClient = new SecretClientBuilder()
.vaultUrl(vaultUrl)
.credential(new ManagedIdentityCredentialBuilder().build())
.retryOptions(retryOptions)
.buildClient();

var retrievedSecret = secretClient.getSecret(secretName);
Expand Down

0 comments on commit 06314e9

Please sign in to comment.