From: Matthew N. Heler Date: Tue, 30 Jun 2026 11:20:39 +0000 (-0500) Subject: rgw/kms: null-check perfcounter before using it X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=84d7550fc8800e0983978304e018c633ad30752d;p=ceph.git rgw/kms: null-check perfcounter before using it Guard the KMS key fetch so we only touch perfcounter when it exists. The fetch latency PerfGuard now sits in an optional and the error counters are wrapped in an if, so both are skipped when perfcounter is null. This keeps key reconstitution working from radosgw-admin (like lc process), where the perfcounter global isn't set up the way it is inside radosgw. Signed-off-by: Matthew N. Heler --- diff --git a/src/rgw/rgw_kms.cc b/src/rgw/rgw_kms.cc index 1961d256123..c9885cdc48e 100644 --- a/src/rgw/rgw_kms.cc +++ b/src/rgw/rgw_kms.cc @@ -6,6 +6,7 @@ */ #include +#include #include "include/str_map.h" #include "common/safe_io.h" #include "rgw/rgw_crypt.h" @@ -1191,10 +1192,12 @@ static int maybe_cache_kms_fetch( if (kms_cache == nullptr || !dpp->get_cct()->_conf->rgw_crypt_s3_kms_cache_enabled) { const auto ret = fetch(actual_key); - if (ret == -ENOENT) { - perfcounter->inc(l_rgw_kms_error_permanent); - } else if (ret < 0) { - perfcounter->inc(l_rgw_kms_error_transient); + if (perfcounter) { + if (ret == -ENOENT) { + perfcounter->inc(l_rgw_kms_error_permanent); + } else if (ret < 0) { + perfcounter->inc(l_rgw_kms_error_transient); + } } return ret; } @@ -1235,7 +1238,10 @@ int reconstitute_actual_key_from_kms( } const auto fetch = [&](std::string& out_secret) -> int { - PerfGuard perf(perfcounter, l_rgw_kms_fetch_lat); + std::optional perf; + if (perfcounter) { + perf.emplace(perfcounter, l_rgw_kms_fetch_lat); + } if (RGW_SSE_KMS_BACKEND_BARBICAN == kms_backend) { return get_actual_key_from_barbican(dpp, key_id, y, out_secret); }