]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/kms: null-check perfcounter before using it 67725/head
authorMatthew N. Heler <matthew.heler@hotmail.com>
Tue, 30 Jun 2026 11:20:39 +0000 (06:20 -0500)
committerMatthew N. Heler <matthew.heler@hotmail.com>
Tue, 30 Jun 2026 15:22:13 +0000 (10:22 -0500)
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 <matthew.heler@hotmail.com>
src/rgw/rgw_kms.cc

index 1961d256123bc6535be1659c5f85c6da118fb6d0..c9885cdc48ed3cb8e675583c4107e4986fac26f5 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <sys/stat.h>
+#include <optional>
 #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<PerfGuard> 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);
     }