RGW: request fields in Lua script return wrong data?
Thanks for your answer. I was able to get the Lua debug log. But I think some request fields don't work: I have this lua script, for example: if Request.HTTP.StorageClass == 'COLD' then RGWDebugLog(Request.RGWOp .. " request with StorageClass: " .. Request.HTTP.StorageClass .. " Obj name: " .. Request.Object.Name .. " Obj ID: " .. Request.Object.Id .. " Size: " .. Request.Object.Size .. " MTime: " .. Request.Object.MTime ) end I put an 1kb object using boto3: s3.Object(bucket, 'test-object6').put(Body="0"*1000, ACL='public-read', StorageClass='COLD') But the size and mtime field provided wrong data? Lua INFO: put_obj request with StorageClass: COLD Obj name: test-object6 Obj ID: test-object6 Size: 0 MTime: 1970-01-01 08:00:00
I think that information on the object exists only in the postRequest context (because only then we accessed the object). to get the size of the object in the preRequest context you need to take it from "Request.ContentLength". see: https://github.com/ceph/ceph/blob/cd5bf7d94251de4667f79591d5832e648ab7ccaa/e... note that this may not be the full size of the object (e.g. in case of multipart upload). let me know if this a usecase you have, as there might be a way to handle this in lua using the global RGW table. On Wed, May 17, 2023 at 6:58 PM <viplanghe6@gmail.com> wrote:
Thanks for your answer. I was able to get the Lua debug log. But I think some request fields don't work:
I have this lua script, for example: if Request.HTTP.StorageClass == 'COLD' then RGWDebugLog(Request.RGWOp .. " request with StorageClass: " .. Request.HTTP.StorageClass .. " Obj name: " .. Request.Object.Name .. " Obj ID: " .. Request.Object.Id .. " Size: " .. Request.Object.Size .. " MTime: " .. Request.Object.MTime ) end
I put an 1kb object using boto3: s3.Object(bucket, 'test-object6').put(Body="0"*1000, ACL='public-read', StorageClass='COLD')
But the size and mtime field provided wrong data? Lua INFO: put_obj request with StorageClass: COLD Obj name: test-object6 Obj ID: test-object6 Size: 0 MTime: 1970-01-01 08:00:00 _______________________________________________ ceph-users mailing list -- ceph-users@ceph.io To unsubscribe send an email to ceph-users-leave@ceph.io
Thanks, postRequest context is what I actually need. The Request.Object.Size is now correct, but MTime is still wrong. Beside that, I also want to print the owner name of bucket or object using Request.User.Tenant, but it doesn't return anything. Script: if Request.HTTP.StorageClass == 'COLD' then RGWDebugLog(Request.RGWOp .. " request with StorageClass: " .. Request.HTTP.StorageClass .. " UserID:" .. tostring(Request.User.Tenant).. " Obj name: " .. Request.Object.Name .. " Obj ID: " .. Request.Object.Id .. " Size: " .. Request.Object.Size .. " MTime: " .. Request.Object.MTime ) end Result: Lua INFO: put_obj request with StorageClass: COLD UserID: Obj name: test-object6 Obj ID: test-object6 Size: 1000 MTime: 1970-01-01 08:00:00
you are right, the object's time has an issue. opened a tracker: https://tracker.ceph.com/issues/61310 to get the bucket owner, use: Request.Bucket.User.Id you can also get that from the user: Request.ObjectOwner.User.Id the "tenant" will be set only if you defined a tenant in your system. and either way. "Request.User.Id/Tenant" will give you the user that sent the request, not necessarily the owner of the bucket. you can also find full documentation of the lua fields here: https://docs.ceph.com/en/latest/radosgw/lua-scripting/ On Sat, May 20, 2023 at 6:12 AM huy nguyen <viplanghe6@gmail.com> wrote:
Thanks, postRequest context is what I actually need. The Request.Object.Size is now correct, but MTime is still wrong. Beside that, I also want to print the owner name of bucket or object using Request.User.Tenant, but it doesn't return anything.
Script: if Request.HTTP.StorageClass == 'COLD' then RGWDebugLog(Request.RGWOp .. " request with StorageClass: " .. Request.HTTP.StorageClass .. " UserID:" .. tostring(Request.User.Tenant).. " Obj name: " .. Request.Object.Name .. " Obj ID: " .. Request.Object.Id .. " Size: " .. Request.Object.Size .. " MTime: " .. Request.Object.MTime )
end
Result: Lua INFO: put_obj request with StorageClass: COLD UserID: Obj name: test-object6 Obj ID: test-object6 Size: 1000 MTime: 1970-01-01 08:00:00 _______________________________________________ ceph-users mailing list -- ceph-users@ceph.io To unsubscribe send an email to ceph-users-leave@ceph.io
participants (3)
-
huy nguyen
-
viplanghe6@gmail.com
-
Yuval Lifshitz