From 2150d8be4f9db743e3c0fc1caa96b76c12289f9d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 22 May 2024 15:24:59 +1000 Subject: [PATCH] Fix some confusing logs around cache flush exodus-gw would log "fastpurge is not enabled" even in cases where fastpurge *was* enabled, but the publish object had no URLs relevant for flush. Many publishes created by exodus-migrator fall into this category. Move the conditionals around a bit so that the log messages are more factual in all cases. --- exodus_gw/worker/cache.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/exodus_gw/worker/cache.py b/exodus_gw/worker/cache.py index 333a56a6..42d832fa 100644 --- a/exodus_gw/worker/cache.py +++ b/exodus_gw/worker/cache.py @@ -97,7 +97,7 @@ def urls_for_flush(self): return out def do_flush(self, urls: list[str]): - if not self.env.fastpurge_enabled or not urls: + if not self.env.fastpurge_enabled: LOG.info("fastpurge is not enabled for %s", self.env.name) return @@ -120,14 +120,16 @@ def do_flush(self, urls: list[str]): def run(self): urls = self.urls_for_flush - self.do_flush(urls) - LOG.info( - "%s flush of %s URL(s) (%s, ...)", - "Completed" if self.env.fastpurge_enabled else "Skipped", - len(urls), - urls[0] if urls else "", - ) + if urls: + self.do_flush(urls) + + LOG.info( + "%s flush of %s URL(s) (%s, ...)", + "Completed" if self.env.fastpurge_enabled else "Skipped", + len(urls), + urls[0], + ) def load_task(db: Session, task_id: str):