Implement updated retry behavior gated behind an internal flag#3678
Implement updated retry behavior gated behind an internal flag#3678ubaskota wants to merge 6 commits intoboto:developfrom
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3678 +/- ##
===========================================
- Coverage 92.59% 92.56% -0.04%
===========================================
Files 68 68
Lines 15634 15767 +133
===========================================
+ Hits 14477 14595 +118
- Misses 1157 1172 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| class TestNewRetriesEnvironmentVariable(unittest.TestCase): | ||
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'true'}) | ||
| def test_env_var_true_enables_new_retries(self): | ||
| importlib.reload(configprovider) | ||
| self.assertTrue(configprovider.NEW_RETRIES_ENABLED) | ||
|
|
||
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'false'}) | ||
| def test_env_var_false_disables_new_retries(self): | ||
| importlib.reload(configprovider) | ||
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | ||
|
|
||
| @mock.patch.dict(os.environ, {}, clear=False) | ||
| def test_no_env_var_uses_default(self): | ||
| os.environ.pop('AWS_NEW_RETRIES_2026', None) | ||
| importlib.reload(configprovider) | ||
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) |
There was a problem hiding this comment.
| class TestNewRetriesEnvironmentVariable(unittest.TestCase): | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'true'}) | |
| def test_env_var_true_enables_new_retries(self): | |
| importlib.reload(configprovider) | |
| self.assertTrue(configprovider.NEW_RETRIES_ENABLED) | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'false'}) | |
| def test_env_var_false_disables_new_retries(self): | |
| importlib.reload(configprovider) | |
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | |
| @mock.patch.dict(os.environ, {}, clear=False) | |
| def test_no_env_var_uses_default(self): | |
| os.environ.pop('AWS_NEW_RETRIES_2026', None) | |
| importlib.reload(configprovider) | |
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | |
| class TestNewRetriesEnvironmentVariable(unittest.TestCase): | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'true'}) | |
| def test_env_var_true_enables_new_retries(self): | |
| self.assertTrue(configprovider._resolve_new_retries()) | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'false'}) | |
| def test_env_var_false_disables_new_retries(self): | |
| self.assertFalse(configprovider._resolve_new_retries()) | |
| def test_no_env_var_uses_default(self): | |
| with mock.patch.dict(os.environ, {}, clear=False): | |
| os.environ.pop('AWS_NEW_RETRIES_2026', None) | |
| self.assertFalse(configprovider._resolve_new_retries()) |
Fact check me here, but I think this will fix the failing CI along with my other suggestion since this doesn't rely on the global module state.
SamRemis
left a comment
There was a problem hiding this comment.
My bad, it still wasn't working. Found some similar tests that use BaseEnvVar, and confirmed this worked on my fork.
| class TestNewRetriesEnvironmentVariable(unittest.TestCase): | ||
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'true'}) | ||
| def test_env_var_true_enables_new_retries(self): | ||
| importlib.reload(configprovider) | ||
| self.assertTrue(configprovider.NEW_RETRIES_ENABLED) | ||
|
|
||
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'false'}) | ||
| def test_env_var_false_disables_new_retries(self): | ||
| importlib.reload(configprovider) | ||
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | ||
|
|
||
| @mock.patch.dict(os.environ, {}, clear=False) | ||
| def test_no_env_var_uses_default(self): | ||
| os.environ.pop('AWS_NEW_RETRIES_2026', None) | ||
| importlib.reload(configprovider) | ||
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) |
There was a problem hiding this comment.
| class TestNewRetriesEnvironmentVariable(unittest.TestCase): | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'true'}) | |
| def test_env_var_true_enables_new_retries(self): | |
| importlib.reload(configprovider) | |
| self.assertTrue(configprovider.NEW_RETRIES_ENABLED) | |
| @mock.patch.dict(os.environ, {'AWS_NEW_RETRIES_2026': 'false'}) | |
| def test_env_var_false_disables_new_retries(self): | |
| importlib.reload(configprovider) | |
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | |
| @mock.patch.dict(os.environ, {}, clear=False) | |
| def test_no_env_var_uses_default(self): | |
| os.environ.pop('AWS_NEW_RETRIES_2026', None) | |
| importlib.reload(configprovider) | |
| self.assertFalse(configprovider.NEW_RETRIES_ENABLED) | |
| class TestNewRetriesEnvironmentVariable(BaseEnvVar): | |
| def test_env_var_true_enables_new_retries(self): | |
| self.environ['AWS_NEW_RETRIES_2026'] = 'true' | |
| self.assertTrue(configprovider._resolve_new_retries()) | |
| def test_env_var_false_disables_new_retries(self): | |
| self.environ['AWS_NEW_RETRIES_2026'] = 'false' | |
| self.assertFalse(configprovider._resolve_new_retries()) | |
| def test_no_env_var_uses_default(self): | |
| self.assertFalse(configprovider._resolve_new_retries()) |
| import importlib | ||
| import os |
There was a problem hiding this comment.
| import importlib | |
| import os |
Description of changes:
Implements the updated retry behavior for standard retry mode. Changes include updated exponential backoff with service specific scale factors, revised retry quota costs (14 for non-throttling, 5 for throttling), DynamoDB-specific max attempts (4) and base backoff (25ms), long-polling operation backoff on quota exhaustion, and
x-amz-retry-afterheader support. All changes are gated behind aSTANDARD_RETRY_MODE_VERSIONflag imported from an internal customization, ensuring no behavior change for external users. The default retry mode is also updated tostandardfor internal users via the same flag.Tests:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.