dimas-b commented on code in PR #3113:
URL: https://github.com/apache/polaris/pull/3113#discussion_r2557376819
##########
polaris-core/src/main/java/org/apache/polaris/core/storage/azure/AzureCredentialsStorageIntegration.java:
##########
@@ -312,16 +318,103 @@ private void validateAccountAndContainer(
});
}
- private AccessToken getAccessToken(String tenantId) {
+ /**
+ * Fetches an Azure AD access token with timeout and retry logic to handle
transient failures.
+ *
+ * <p>This access token is used internally to obtain a user delegation key
from Azure Storage,
+ * which is then used to generate SAS tokens for client credential vending.
+ *
+ * <p>This method implements a defensive strategy against slow or failing
cloud provider requests:
+ *
+ * <ul>
+ * <li>Per-attempt timeout (configurable via CLOUD_API_TIMEOUT_SECONDS,
default 15s)
+ * <li>Exponential backoff retry (configurable count and initial delay via
CLOUD_API_RETRY_COUNT
+ * and CLOUD_API_RETRY_DELAY_SECONDS, defaults: 3 attempts starting at
2s)
+ * <li>Jitter to prevent thundering herd (configurable via
CLOUD_API_RETRY_JITTER_MILLIS, default 500ms)
+ * </ul>
+ *
+ * @param realmConfig the realm configuration to get timeout and retry
settings
+ * @param tenantId the Azure tenant ID
+ * @return the access token
+ * @throws RuntimeException if token fetch fails after all retries or times
out
+ */
+ private AccessToken getAccessToken(RealmConfig realmConfig, String tenantId)
{
+ int timeoutSeconds = realmConfig.getConfig(CLOUD_API_TIMEOUT_SECONDS);
+ int retryCount = realmConfig.getConfig(CLOUD_API_RETRY_COUNT);
+ int initialDelaySeconds =
realmConfig.getConfig(CLOUD_API_RETRY_DELAY_SECONDS);
Review Comment:
Would you mind using millis for `initialDelaySeconds`... in some cases even
1 sec may be too long. Let's delegate what the min delay should be to the admin
user who configures it.
Same for `timeoutSeconds`... I hope Azure SDK supports millis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]