CloudRetry/AWSRetry : Disable catching of NotFound exceptions (#67281)

* CloudRetry/AWSRetry : Remove default catching of NotFound exceptions

* Add docs

* Changelog updates from review

* Update unit tests after removing 'NotFound' from default retries
This commit is contained in:
Mark Chappell 2020-02-13 22:59:00 +01:00 committed by GitHub
parent 1a450400ff
commit 90898132e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- "The ``AWSRetry`` decorator no longer catches ``NotFound`` exceptions unless they're explicitly added via ``catch_extra_error_codes``."

View file

@ -102,6 +102,7 @@ Noteworthy module changes
* The ``datacenter`` option has been removed from :ref:`vmware_guest_find <vmware_guest_find_module>`
* The options ``ip_address`` and ``subnet_mask`` have been removed from :ref:`vmware_vmkernel <vmware_vmkernel_module>`; use the suboptions ``ip_address`` and ``subnet_mask`` of the ``network`` option instead.
* Ansible modules created with ``add_file_common_args=True`` added a number of undocumented arguments which were mostly there to ease implementing certain action plugins. The undocumented arguments ``src``, ``follow``, ``force``, ``content``, ``backup``, ``remote_src``, ``regexp``, ``delimiter``, and ``directory_mode`` are now no longer added. Modules relying on these options to be added need to specify them by themselves.
* The ``AWSRetry`` decorator no longer catches ``NotFound`` exceptions by default. ``NotFound`` exceptions need to be explicitly added using ``catch_extra_error_codes``. Some AWS modules may see an increase in transient failures due to AWS's eventual consistency model.
* :ref:`vmware_datastore_maintenancemode <vmware_datastore_maintenancemode_module>` now returns ``datastore_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_host_kernel_manager <vmware_host_kernel_manager_module>` now returns ``host_kernel_status`` instead of Ansible internal key ``results``.
* :ref:`vmware_host_ntp <vmware_host_ntp_module>` now returns ``host_ntp_status`` instead of Ansible internal key ``results``.

View file

@ -111,8 +111,7 @@ class AWSRetry(CloudRetry):
if catch_extra_error_codes:
retry_on.extend(catch_extra_error_codes)
not_found = re.compile(r'^\w+.NotFound')
return response_code in retry_on or not_found.search(response_code)
return response_code in retry_on
def boto3_conn(module, conn_type=None, resource=None, region=None, endpoint=None, **params):

View file

@ -43,7 +43,7 @@ class RetryTestCase(unittest.TestCase):
def extend_failures():
self.counter += 1
if self.counter < 2:
raise botocore.exceptions.ClientError(err_msg, 'Could not find you')
raise botocore.exceptions.ClientError(err_msg, 'You did something wrong.')
else:
return 'success'
@ -53,13 +53,13 @@ class RetryTestCase(unittest.TestCase):
def test_retry_once(self):
self.counter = 0
err_msg = {'Error': {'Code': 'InstanceId.NotFound'}}
err_msg = {'Error': {'Code': 'InternalFailure'}}
@AWSRetry.backoff(tries=2, delay=0.1)
def retry_once():
self.counter += 1
if self.counter < 2:
raise botocore.exceptions.ClientError(err_msg, 'Could not find you')
raise botocore.exceptions.ClientError(err_msg, 'Something went wrong!')
else:
return 'success'