]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: Fix healthchecks requests to not goto backend storage.
authorkchheda3 <kchheda3@bloomberg.net>
Fri, 24 Jan 2025 14:43:41 +0000 (09:43 -0500)
committerkchheda3 <kchheda3@bloomberg.net>
Thu, 6 Feb 2025 15:32:47 +0000 (10:32 -0500)
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
PendingReleaseNotes
src/rgw/rgw_process.cc

index d25acfa9c6d7743fee489bdc535eae2679eb48b7..e17372de294b587e354103a114e4205784ccce67 100644 (file)
@@ -10,6 +10,7 @@
     * use of tenant names instead of accounts in IAM policy documents,
     * interpretation of IAM policy without cross-account policy evaluation,
     * S3 API support for cross-tenant names such as `Bucket='tenant:bucketname'`
+* 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
index 9ad599b3252337a0fe33acbeda4a340a28b7b5c8..47f1eb0fc10e13c927f88b5bd38e2c88d8a12f72 100644 (file)
@@ -307,6 +307,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,
@@ -327,18 +328,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, 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, s, op, script);
+        if (rc < 0) {
+          ldpp_dout(op, 5) <<
+            "WARNING: failed to execute pre request script. "
+            "error: " << rc << dendl;
+        }
       }
     }
   }
@@ -419,16 +429,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, 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, s, op, script);
+        if (rc < 0) {
+          ldpp_dout(op, 5) <<
+            "WARNING: failed to execute post request script. "
+            "error: " << rc << dendl;
+        }
       }
     }
   }