From b7156876179e70ec43297c9cd6bf651966028c86 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 3 Mar 2017 16:03:52 -0800 Subject: [PATCH] Ensuring that we don't fail cleaning if it doesn't exist. (#708) --- lemur/plugins/lemur_aws/iam.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lemur/plugins/lemur_aws/iam.py b/lemur/plugins/lemur_aws/iam.py index 429403b5..9a4408ff 100644 --- a/lemur/plugins/lemur_aws/iam.py +++ b/lemur/plugins/lemur_aws/iam.py @@ -24,6 +24,9 @@ def retry_throttled(exception): if exception.response['Error']['Code'] == 'NoSuchEntity': return False + if isinstance(exception, botocore.errorfactory.NoSuchEntityException): + return False + metrics.send('iam_retry', 'counter', 1) return True @@ -93,7 +96,11 @@ def delete_cert(cert_name, **kwargs): :return: """ client = kwargs.pop('client') - client.delete_server_certificate(ServerCertificateName=cert_name) + try: + client.delete_server_certificate(ServerCertificateName=cert_name) + except botocore.exceptions.ClientError as e: + if e.response['Error']['Code'] != 'NoSuchEntity': + raise e @sts_client('iam')