From 7695247021ba100215589bf691ccfbae48f0e5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20M=C3=A9ndez=20Hern=C3=A1ndez?= Date: Wed, 6 May 2026 00:08:07 +0200 Subject: [PATCH] Fixes #39292 - Add cache HIT/MISS logging for Candlepin proxy caches Emit debug-level log lines via the :registration named logger (Foreman #39290) for each cached Candlepin endpoint: - compliance cache: "compliance cache=HIT/MISS uuid=" - candlepin status cache: "rhsm_status cache=HIT/MISS" At the default info level, no additional log lines appear. Enable with :registration logger at debug level. Depends on: - Foreman #39290 (:registration named logger) - Katello #39195 (compliance cache) - Katello #39204 (candlepin status cache) Co-Authored-By: Claude Opus 4.6 (1M context) --- app/lib/katello/resources/candlepin/candlepin_ping.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/lib/katello/resources/candlepin/candlepin_ping.rb b/app/lib/katello/resources/candlepin/candlepin_ping.rb index 846ca08ec6f..0e27d3b2a44 100644 --- a/app/lib/katello/resources/candlepin/candlepin_ping.rb +++ b/app/lib/katello/resources/candlepin/candlepin_ping.rb @@ -8,10 +8,15 @@ class CandlepinPing < CandlepinResource class << self def ping(try_cache: false) - Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_TTL, race_condition_ttl: RACE_TTL, force: !try_cache) do + cache_miss = false + result = Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_TTL, race_condition_ttl: RACE_TTL, force: !try_cache) do + cache_miss = true + ::Foreman::Logging.logger('registration').debug "rhsm_status cache=MISS" response = get('/candlepin/status').body JSON.parse(response).with_indifferent_access end + ::Foreman::Logging.logger('registration').debug "rhsm_status cache=HIT" unless cache_miss || !try_cache + result end def ok?