Skip to content

rgw: Add Lua functionality for blocking requests - #66065

Merged
yuvalif merged 1 commit into
ceph:mainfrom
mertsunacoglu:wip-lua-abort
Feb 23, 2026
Merged

yuvalif merged 1 commit into
ceph:mainfrom
mertsunacoglu:wip-lua-abort

Conversation

@mertsunacoglu

@mertsunacoglu mertsunacoglu commented Oct 27, 2025 •

Copy link
Copy Markdown
Contributor

https://tracker.ceph.com/issues/73485

This PR implements the feature for RGW to abort requests when the LUA scripts return a certain error code. This code is implemented in LUA as RGW_ABORT_REQUEST, and in RGW it is interpreted as -EPERM.

The changes should not affect already existing Lua scripts people have.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@mertsunacoglu
mertsunacoglu requested a review from a team as a code owner October 27, 2025 09:47
@cbodley
cbodley requested a review from yuvalif October 27, 2025 15:11
@jmundack

Copy link
Copy Markdown
Contributor

@mertsunacoglu

ceph/src/test/rgw/test_rgw_lua.cc:1684:80: error: use of undeclared identifier 'return_code'
 1684 |   const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script, return_code);

build failure from the Jenkins jobs. Mind taking a look?

@mertsunacoglu

Copy link
Copy Markdown
Contributor Author

@jmundack I have changed the parameters that was causing the error. It was an oversight from my side, but the jenkins job still seems to be failing for a reason I am not sure how to check for.

@jmundack

Copy link
Copy Markdown
Contributor

jenkins test make check

@jmundack

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

Comment thread src/rgw/rgw_lua_request.cc Resolved
@yuvalif

yuvalif commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

jenkins test docs

@yuvalif

yuvalif commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@yuvalif

yuvalif commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

please add information about the new behavior in the doc: https://github.com/ceph/ceph/blob/main/doc/radosgw/lua-scripting.rst
please indicate:

  • what happens if there is an error in the script
  • which context take the value into consideration
  • what happens if a value different than -EPRM is used

Comment thread doc/radosgw/lua-scripting.rst Resolved
Comment thread doc/radosgw/lua-scripting.rst Resolved
@databus23

Copy link
Copy Markdown

This is a really useful feature. Thanks for looking into this. 🚀
Is my assumption correct that when rejecting a request it is still possible to define the http status code and message via Request.Response... fields even when rejecting a request?

@yuvalif yuvalif removed the needs-doc label Nov 3, 2025
@yuvalif

yuvalif commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

This is a really useful feature. Thanks for looking into this. 🚀 Is my assumption correct that when rejecting a request it is still possible to define the http status code and message via Request.Response... fields even when rejecting a request?

thats a great question. we probably need to add to the doc:

  • what would be the HTTP return code if nothing is set in the request?
  • how to set a specific return code via Request.Response.HTTPStatusCode

we should probably also add a note that if a message is a borted, the data and postrequest context will not be executed against this message

@mertsunacoglu

Copy link
Copy Markdown
Contributor Author

By default, the HTTP response is 403 (Forbidden) when the request is blocked this way, but it can be changed via Request.Response.HTTPStatusCode. Updated the documentation accordingly.

@databus23

Copy link
Copy Markdown

Thanks. Is it also possible to set a message that is shown to the user with an aborted request? That would be really useful to communicate to the user why a request was blocked/aborted in detail.

@mertsunacoglu

Copy link
Copy Markdown
Contributor Author

Yes, it is also possible to change the Request.Response.Message to communicate longer messages with the user in Lua. We might try to find a better default HTTP response in the future, keeping these in mind.

Comment thread doc/radosgw/lua-scripting.rst Resolved
Comment thread doc/radosgw/lua-scripting.rst Resolved
@mertsunacoglu

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Implements the feature for RGW to abort requests when the LUA scripts return a certain error code. This code is implemented in LUA as RGW_ABORT_REQUEST, and in RGW it is interpreted as -EPERM.

Fixes: https://tracker.ceph.com/issues/73485

Signed-off-by: mertsunacoglu <[email protected]>
@mertsunacoglu

Copy link
Copy Markdown
Contributor Author

The location of the prerequest hook changed in the rgw_process, causing a merge conflict

irq0 added a commit to irq0/ceph that referenced this pull request Feb 20, 2026
…ase/cobaltcore-storage-v19.2.3+fasttrack-1

PRs:

ceph#66065
ceph#67219
ceph#66567

* backports/19.2.3/emin-wip-postauth-lua-squid:
  backport: Add a variable to the execute function call in unittests
  Add latest changes to the Bucket Tags PR
  Limit bucket metadata access to decoded tags only. Fixes: https://tracker.ceph.com/issues/74756
  Adjust function signiture to the legacy code
  Change auth to execute before prerequest
  Update doc/radosgw/lua-scripting.rst
  Update doc/radosgw/lua-scripting.rst
  rgw: Update documentation for lua request blocking behavior Fixes: https://tracker.ceph.com/issues/73485
  Update doc/radosgw/lua-scripting.rst
  Update doc/radosgw/lua-scripting.rst
  rgw: Document lua request blocking behavior
  rgw:use lua_isinteger() for lua script return value
  rgw:Add Tests for Lua blocking requests in RGW
  rgw: Add Lua functionality for blocking requests
@anrao19

anrao19 commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Execution complete, tracker approved by @ivancich. tracker detail: https://tracker.ceph.com/issues/73732
@mertsunacoglu , If no further testing needed, pr can be merged

@yuvalif
yuvalif merged commit cb6a2e9 into ceph:main Feb 23, 2026
6 checks passed
irq0 added a commit to irq0/ceph that referenced this pull request Feb 25, 2026
…ase/cobaltcore-storage-v19.2.3-fasttrack-2

PRs:

ceph#66065
ceph#67219
ceph#66567

* backports/19.2.3/emin-wip-postauth-lua-squid:
  backport: Add a variable to the execute function call in unittests
  Add latest changes to the Bucket Tags PR
  Limit bucket metadata access to decoded tags only. Fixes: https://tracker.ceph.com/issues/74756
  Adjust function signiture to the legacy code
  Change auth to execute before prerequest
  Update doc/radosgw/lua-scripting.rst
  Update doc/radosgw/lua-scripting.rst
  rgw: Update documentation for lua request blocking behavior Fixes: https://tracker.ceph.com/issues/73485
  Update doc/radosgw/lua-scripting.rst
  Update doc/radosgw/lua-scripting.rst
  rgw: Document lua request blocking behavior
  rgw:use lua_isinteger() for lua script return value
  rgw:Add Tests for Lua blocking requests in RGW
  rgw: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 6, 2026
…tcore-storage-v19.2.3-fasttrack-4

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 6, 2026
…tcore-storage-v19.2.3-fasttrack-5

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 10, 2026
…tcore-storage-v19.2.3-fasttrack-6

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 10, 2026
…tcore-storage-v19.2.3-fasttrack-7

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 10, 2026
…tcore-storage-v19.2.3-fasttrack-8

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Mar 11, 2026
…tcore-storage-v19.2.3-fasttrack-9

PR ceph#66065, ceph#67219, ceph#66567, ceph#67548

* backports/19.2.3/emin-lua-writelock:
  rgw/lua: Add teuthology test for writelock
  backport: Add the missing driver attribute in the execute function
  rgw: Add new Lua postAuth hook that is being run after authorization
  rgw: Add Bucket tags attribute for Lua scripts
  rgw/lua: Add Lua functionality for blocking requests
irq0 added a commit to irq0/ceph that referenced this pull request Jun 4, 2026
Retroactive <uuid>.md for the Lua write-lock backport (postAuth hook,
bucket tags, request blocking) already landed on this branch as merge
commit 14149f3.

Backport-Id: 019e92ed-d2cb-72c0-a34e-b5bf55eac620
Backport-Merge: 14149f3
Upstream-PRs: ceph#66065, ceph#67219, ceph#66567, ceph#67548
irq0 added a commit to cobaltcore-dev/ceph that referenced this pull request Jun 10, 2026
Backport-Id: 019eb1e8-4991-7231-abf9-77cb82dcb746
Backport-PR: #6
Upstream-PRs: ceph#67219, ceph#67548, ceph#66065
uw-sc added a commit to cobaltcore-dev/ceph that referenced this pull request Sep 25, 2026
Backport-Id: 01a0d3b1-e48a-7f08-ab0d-0a549f628691
Backport-PR: #17
Upstream-PRs: ceph#67219, ceph#67548, ceph#66065
uw-sc added a commit to cobaltcore-dev/ceph that referenced this pull request Oct 8, 2026
Backport-Id: 01a11b0e-da4d-7890-bfeb-43841f3aab2d
Backport-PR: #24
Upstream-PRs: ceph#67219, ceph#67548, ceph#66065
uw-sc added a commit to cobaltcore-dev/ceph that referenced this pull request Oct 14, 2026
Backport-Id: 01a0d3b1-e48a-7f08-ab0d-0a549f628691
Backport-PR: #17
Upstream-PRs: ceph#67219, ceph#67548, ceph#66065
uw-sc added a commit to cobaltcore-dev/ceph that referenced this pull request Oct 16, 2026
Backport-Id: 01a14402-60b5-7b0e-9e40-46b110a790de
Backport-PR: #32
Upstream-PRs: ceph#67219, ceph#67548, ceph#66065
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants