Skip to content

Commit 24a53ef

Browse files
committed
Added better error handling to specify NoSuchTagSet error
1 parent 77d3d0f commit 24a53ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/util/k8s/terminate_cluster.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,12 @@ def delete_expired_tf_state_s3_buckets():
983983
created_date = bucket["CreationDate"]
984984
try:
985985
tags = s3_client.get_bucket_tagging(Bucket=bucket["Name"])["TagSet"]
986-
except botocore.exceptions.ClientError:
987-
raise RuntimeError(f"S3 bucket {bucket['Name']} does not have any tags.")
986+
except botocore.exceptions.ClientError as e:
987+
if e.response['Error']['Code'] == 'NoSuchTagSet':
988+
raise RuntimeError(f"S3 bucket {bucket['Name']} does not have any tags.")
989+
else:
990+
logging.error(f"Unexpected error for bucket: {bucket['Name']}")
991+
raise e
988992
persist_days = next((tag["Value"] for tag in tags if tag["Key"] == "persist_days"), None)
989993
if persist_days:
990994
if not is_float(persist_days):

0 commit comments

Comments
 (0)