File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -506,6 +506,11 @@ namespace Aws
506506 * Timeout in seconds when retrieving data from IMDS. Default 1.
507507 */
508508 long metadataServiceTimeout = 1 ;
509+
510+ /* *
511+ * Retry Strategy for IMDS
512+ */
513+ std::shared_ptr<RetryStrategy> imdsRetryStrategy;
509514 } imdsConfig;
510515 }credentialProviderConfig;
511516 };
@@ -515,6 +520,7 @@ namespace Aws
515520 * Default is DefaultRetryStrategy (i.e. exponential backoff)
516521 */
517522 std::shared_ptr<RetryStrategy> InitRetryStrategy (Aws::String retryMode = " " );
523+ std::shared_ptr<RetryStrategy> InitRetryStrategy (int maxAttempts, Aws::String retryMode = " " );
518524
519525 /* *
520526 * A helper function to compute a user agent
Original file line number Diff line number Diff line change @@ -315,10 +315,9 @@ void setConfigFromEnvOrProfile(ClientConfiguration &config)
315315 long attempts = static_cast <long >(Aws::Utils::StringUtils::ConvertToInt32 (numAttemptsStr.c_str ()));
316316 config.credentialProviderConfig .imdsConfig .metadataServiceNumAttempts = attempts;
317317
318- // Ensure retry strategy is set using factory pattern
319- if (!config.retryStrategy ) {
320- config.retryStrategy = config.configFactories .retryStrategyCreateFn ();
321- }
318+ // Initialize IMDS-specific retry strategy with configured number of attempts
319+ // Uses default retry mode with the specified max attempts from metadata_service_num_attempts
320+ config.credentialProviderConfig .imdsConfig .imdsRetryStrategy = InitRetryStrategy (attempts, " " );
322321}
323322
324323ClientConfiguration::ClientConfiguration ()
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ namespace Aws
8282 AWSHttpResourceClient::AWSHttpResourceClient (const Aws::Client::ClientConfiguration& clientConfiguration, const char * logtag)
8383 : m_logtag(logtag),
8484 m_userAgent (Aws::Client::ComputeUserAgentString(&clientConfiguration)),
85- m_retryStrategy(clientConfiguration.retryStrategy),
85+ m_retryStrategy(clientConfiguration.retryStrategy ? clientConfiguration.retryStrategy : clientConfiguration.configFactories.retryStrategyCreateFn() ),
8686 m_httpClient(nullptr )
8787 {
8888 AWS_LOGSTREAM_INFO (m_logtag.c_str (),
@@ -213,10 +213,8 @@ namespace Aws
213213 [&credentialConfig]() -> ClientConfiguration{
214214 Aws::Client::ClientConfiguration clientConfig;
215215 clientConfig.credentialProviderConfig = credentialConfig;
216- clientConfig.connectTimeoutMs = credentialConfig.imdsConfig .metadataServiceTimeout * 1000 ;
217216 clientConfig.requestTimeoutMs = credentialConfig.imdsConfig .metadataServiceTimeout * 1000 ;
218- clientConfig.retryStrategy = Aws::MakeShared<DefaultRetryStrategy>(
219- RESOURCE_CLIENT_CONFIGURATION_ALLOCATION_TAG, credentialConfig.imdsConfig .metadataServiceNumAttempts - 1 , 1000 );
217+ clientConfig.retryStrategy = credentialConfig.imdsConfig .imdsRetryStrategy ;
220218 return clientConfig;
221219 }(),
222220 EC2_METADATA_CLIENT_LOG_TAG),
You can’t perform that action at this time.
0 commit comments