From 39b4d38a3d06f6022f08cf8ca5fc7f5e5ae8a1e3 Mon Sep 17 00:00:00 2001 From: kchheda3 Date: Fri, 24 Jan 2025 09:43:41 -0500 Subject: [PATCH] rgw/lua: Fix healthchecks requests to not goto backend storage. Signed-off-by: kchheda3 --- PendingReleaseNotes | 1 + src/rgw/rgw_process.cc | 58 +++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index d25acfa9c6d..e17372de294 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -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 diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 9ad599b3252..47f1eb0fc10 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -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; + } } } } -- 2.39.5