From adde08c54801bec27b5cc96ad39fec4ebe5e23a3 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Thu, 11 Apr 2024 12:10:12 +0800 Subject: [PATCH] Refine the output for cf invalidation request --- charon/cache.py | 5 ++++- charon/pkgs/pkg_utils.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/charon/cache.py b/charon/cache.py index 17ea22ac..652fe8b6 100644 --- a/charon/cache.py +++ b/charon/cache.py @@ -12,6 +12,9 @@ INVALIDATION_BATCH_DEFAULT = 3000 INVALIDATION_BATCH_WILDCARD = 15 +INVALIDATION_STATUS_COMPLETED = "Completed" +INVALIDATION_STATUS_INPROGRESS = "InProgress" + DEFAULT_BUCKET_TO_DOMAIN = { "prod-ga": "maven.repository.redhat.com", "prod-maven-ga": "maven.repository.redhat.com", @@ -91,7 +94,7 @@ def invalidate_paths( current_invalidation = {} for batch_paths in real_paths: while (current_invalidation and - 'InProgress' == current_invalidation.get('Status', '')): + INVALIDATION_STATUS_INPROGRESS == current_invalidation.get('Status', '')): time.sleep(5) try: result = self.check_invalidation(distr_id, current_invalidation.get('Id')) diff --git a/charon/pkgs/pkg_utils.py b/charon/pkgs/pkg_utils.py index 88c31257..7d9cabc7 100644 --- a/charon/pkgs/pkg_utils.py +++ b/charon/pkgs/pkg_utils.py @@ -104,9 +104,15 @@ def invalidate_cf_paths( distr_id, final_paths, real_batch_size ) if result: + output = {} + for invalidation in result: + status = invalidation.get('Status') + if status not in output: + output[status] = [] + output[status].append(invalidation["Id"]) logger.info( "The CF invalidating request for metadata/indexing is sent, " - "request status as below:\n %s", result + "request result as below:\n %s", output ) else: logger.error(