From de08a9dce2818a8dc81bd98498a2c298cd238d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Sun, 15 May 2022 08:02:59 -0400 Subject: [PATCH] ec2_transit_gateway_IncorrectState: retry on IncorrectState (#1110) * ec2_transit_gateway_IncorrectState: retry on IncorrectState Do not immediately bail out in case of IncorrectState error. We now instead wait and retry. E.g: https://ddf1d621d7b816539203-e56a3e9170eb32404c2ff3e77b13356f.ssl.cf2.rackcdn.com/799/690df9c2d3f69323837542b96fa7318650fd5308/check/integration-community.aws-1/f30fb4f/job-output.txt --- .../fragments/ec2_transit_gateway_IncorrectState.yaml | 3 +++ plugins/modules/ec2_transit_gateway.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ec2_transit_gateway_IncorrectState.yaml diff --git a/changelogs/fragments/ec2_transit_gateway_IncorrectState.yaml b/changelogs/fragments/ec2_transit_gateway_IncorrectState.yaml new file mode 100644 index 00000000000..0668d630491 --- /dev/null +++ b/changelogs/fragments/ec2_transit_gateway_IncorrectState.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: +- ec2_transit_gateway - wait and retry if API returns an IncorrectState error. diff --git a/plugins/modules/ec2_transit_gateway.py b/plugins/modules/ec2_transit_gateway.py index c013ea67379..4237376203b 100644 --- a/plugins/modules/ec2_transit_gateway.py +++ b/plugins/modules/ec2_transit_gateway.py @@ -242,7 +242,11 @@ class AnsibleEc2Tgw(object): def __init__(self, module, results): self._module = module self._results = results - self._connection = self._module.client('ec2') + retry_decorator = AWSRetry.jittered_backoff( + catch_extra_error_codes=['IncorrectState'], + ) + connection = module.client('ec2', retry_decorator=retry_decorator) + self._connection = connection self._check_mode = self._module.check_mode def process(self):