From 016761f817546bf3e0b92d0274b69075cae36680 Mon Sep 17 00:00:00 2001 From: sabiurr Date: Mon, 14 Nov 2022 17:07:19 -0500 Subject: [PATCH] Add error handling when trying to fetch lambda custom tags (#619) * Handle error when building lambda tags cache * remove comments --- aws/logs_monitoring/cache.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aws/logs_monitoring/cache.py b/aws/logs_monitoring/cache.py index 980b587fc..e978a7bb7 100644 --- a/aws/logs_monitoring/cache.py +++ b/aws/logs_monitoring/cache.py @@ -203,10 +203,12 @@ def _refresh(self): logger.debug("S3 cache expired, rebuilding cache") lock_acquired = self.acquire_s3_cache_lock() if lock_acquired: - success, tags_fetched = self.build_tags_cache() + success, new_tags_fetched = self.build_tags_cache() if success: - self.tags_by_id = tags_fetched + self.tags_by_id = new_tags_fetched self.write_cache_to_s3(self.tags_by_id) + elif tags_fetched != {}: + self.tags_by_id = tags_fetched self.release_s3_cache_lock() # s3 cache fetch succeeded and isn't expired @@ -328,6 +330,7 @@ def build_tags_cache(self): send_forwarder_internal_metrics( "client_error", additional_tags=additional_tags ) + tags_fetch_success = False logger.debug( "Built this tags cache from GetResources API calls: %s", tags_by_arn_cache