]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: Fix healthchecks requests to not goto backend storage. 62034/head
authorkchheda3 <kchheda3@bloomberg.net>
Fri, 24 Jan 2025 14:43:41 +0000 (09:43 -0500)
committerkchheda3 <kchheda3@bloomberg.net>
Tue, 25 Mar 2025 13:36:44 +0000 (13:36 +0000)
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
(cherry picked from commit 39b4d38a3d06f6022f08cf8ca5fc7f5e5ae8a1e3)

PendingReleaseNotes
src/rgw/rgw_process.cc

index 05750c27605073f63e6f87dac27d4b177f979cb1..57e496cde9c156e4e1bd92bbb1f2318309760b75 100644 (file)
@@ -1,5 +1,7 @@
 >=20.0.0
 
+* RGW: Lua scripts will not run against health checks.
+
 * RBD: All Python APIs that produce timestamps now return "aware" `datetime`
   objects instead of "naive" ones (i.e. those including time zone information
   instead of those not including it).  All timestamps remain to be in UTC but
index c1c16a88d9763dbf547de32a0f6247058f18216e..8c3f3b726e058d36b7ed4b0b7ff0cedb79c8b5c3 100644 (file)
@@ -306,6 +306,7 @@ int process_request(const RGWProcessEnv& penv,
   bool should_log = false;
   RGWREST* rest = penv.rest;
   RGWRESTMgr *mgr;
+  bool is_health_request = false;
   RGWHandler_REST *handler = rest->get_handler(driver, s,
                                                *penv.auth_registry,
                                                frontend_prefix,
@@ -326,18 +327,27 @@ int process_request(const RGWProcessEnv& penv,
     abort_early(s, NULL, -ERR_METHOD_NOT_ALLOWED, handler, yield);
     goto done;
   }
+  is_health_request = (op->get_type() == RGW_OP_GET_HEALTH_CHECK);
   {
     s->trace_enabled = tracing::rgw::tracer.is_enabled();
-    std::string script;
-    auto rc = rgw::lua::read_script(s, penv.lua.manager.get(), s->bucket_tenant, s->yield, rgw::lua::context::preRequest, script);
-    if (rc == -ENOENT) {
-      // no script, nothing to do
-    } else if (rc < 0) {
-      ldpp_dout(op, 5) << "WARNING: failed to read pre request script. error: " << rc << dendl;
-    } else {
-      rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, script);
-      if (rc < 0) {
-        ldpp_dout(op, 5) << "WARNING: failed to execute pre request script. error: " << rc << dendl;
+    if (!is_health_request) {
+      std::string script;
+      auto rc = rgw::lua::read_script(s, penv.lua.manager.get(),
+                                      s->bucket_tenant, s->yield,
+                                      rgw::lua::context::preRequest, script);
+      if (rc == -ENOENT) {
+        // no script, nothing to do
+      } else if (rc < 0) {
+        ldpp_dout(op, 5) <<
+          "WARNING: failed to execute pre request script. "
+          "error: " << rc << dendl;
+      } else {
+        rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, script);
+        if (rc < 0) {
+          ldpp_dout(op, 5) <<
+            "WARNING: failed to execute pre request script. "
+            "error: " << rc << dendl;
+        }
       }
     }
   }
@@ -418,16 +428,24 @@ done:
         s->trace->SetAttribute(tracing::rgw::OBJECT_NAME, s->object->get_name());
       }
     }
-    std::string script;
-    auto rc = rgw::lua::read_script(s, penv.lua.manager.get(), s->bucket_tenant, s->yield, rgw::lua::context::postRequest, script);
-    if (rc == -ENOENT) {
-      // no script, nothing to do
-    } else if (rc < 0) {
-      ldpp_dout(op, 5) << "WARNING: failed to read post request script. error: " << rc << dendl;
-    } else {
-      rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, script);
-      if (rc < 0) {
-        ldpp_dout(op, 5) << "WARNING: failed to execute post request script. error: " << rc << dendl;
+    if (!is_health_request) {
+      std::string script;
+      auto rc = rgw::lua::read_script(s, penv.lua.manager.get(),
+                                      s->bucket_tenant, s->yield,
+                                      rgw::lua::context::postRequest, script);
+      if (rc == -ENOENT) {
+        // no script, nothing to do
+      } else if (rc < 0) {
+        ldpp_dout(op, 5) <<
+          "WARNING: failed to read post request script. "
+          "error: " << rc << dendl;
+      } else {
+        rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, script);
+        if (rc < 0) {
+          ldpp_dout(op, 5) <<
+            "WARNING: failed to execute post request script. "
+            "error: " << rc << dendl;
+        }
       }
     }
   }