Repository navigation
[Identity] Add custom IMDS retry policy - #42330
Conversation
This custom policy adds logic to increase the retry backoff factor in the event that a response is a 410. It can take up to 70 seconds for IMDS to become available. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
c8bfb0d to
bcf51a9
Compare
Idependencies { |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a custom IMDS retry policy to the Azure Identity library to handle IMDS endpoint unavailability scenarios. The change specifically addresses the requirement that IMDS 410 status responses should be retried for at least 70 seconds total duration, as documented in Azure IMDS specifications.
Key changes:
- Introduces custom retry policies (
ImdsRetryPolicyandAsyncImdsRetryPolicy) with extended backoff for 410 responses - Modifies pipeline construction to support custom retry policy classes
- Updates IMDS credential classes to use the new custom retry policies
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
azure/identity/_credentials/imds.py |
Adds ImdsRetryPolicy class and updates ImdsCredential to use custom retry policy |
azure/identity/aio/_credentials/imds.py |
Adds AsyncImdsRetryPolicy class and updates async ImdsCredential to use custom retry policy |
azure/identity/_internal/pipeline.py |
Modifies pipeline builders to support custom retry policy classes via retry_policy_class parameter |
tests/test_imds_credential.py |
Adds comprehensive tests for the new retry policy behavior |
tests/test_imds_credential_async.py |
Adds comprehensive tests for the async retry policy behavior |
CHANGELOG.md |
Documents the new retry behavior for IMDS 410 responses |
Comments suppressed due to low confidence (2)
sdk/identity/azure-identity/tests/test_imds_credential.py:160
- The test doesn't verify the backoff factor is reset after handling a 410 response. Consider adding a test case that verifies the policy correctly resets the backoff factor when switching from a 410 response to a different status code.
request = Mock(spec=HttpRequest, body=None, files=None)
sdk/identity/azure-identity/tests/test_imds_credential_async.py:366
- The async test has the same limitation as the sync version - it doesn't verify the backoff factor is reset after handling a 410 response. Consider adding a test case that verifies the policy correctly resets the backoff factor when switching from a 410 response to a different status code.
request = Mock(spec=HttpRequest, body=None, files=None)
This custom policy adds logic to increase the retry backoff factor in the event that a response is a 410. It can take up to 70 seconds for IMDS to become available.
Closes: #41741