Last active
June 6, 2025 13:46
-
-
Save yuvalif/8f27ebcdcd118264652bfdb96217d95e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Lua script to auto-tier S3 object PUT requests | |
-- based on this: https://ceph.io/en/news/blog/2024/auto-tiering-ceph-object-storage-part-2/ | |
-- exit script quickly if it is not a PUT request | |
if Request == nil or Request.RGWOp ~= "put_obj" then | |
return | |
end | |
local threshold = 1024*1024 -- 1MB | |
local debug = true | |
-- apply StorageClass only if user hasn't already assigned a storage-class | |
if Request.HTTP.StorageClass == nil or Request.HTTP.StorageClass == '' then | |
if Request.ContentLength < threshold then | |
Request.HTTP.StorageClass = "SMALL_OBJ" | |
else | |
Request.HTTP.StorageClass = "STANDARD" | |
end | |
if debug then | |
RGWDebugLog("applied '" .. Request.HTTP.StorageClass .. "' to object '" .. Request.Object.Name .. "'") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment