Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active January 3, 2023 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuvalif/3cf2e22247e1a287b7fff1c9cfd0dad2 to your computer and use it in GitHub Desktop.
Save yuvalif/3cf2e22247e1a287b7fff1c9cfd0dad2 to your computer and use it in GitHub Desktop.
  • start ceph cluster with an RGW using vstart:
MON=1 OSD=1 MDS=0 MGR=1 RGW=1 ../src/vstart.sh -d -n
  • use the following lua script postrequest.lua:
RGWDebugLog("Post Request Request.RGWOp = " .. Request.RGWOp)

RGWDebugLog("number of http metadata entries is: " .. #Request.HTTP.Metadata)
for k, v in pairs(Request.HTTP.Metadata) do
  RGWDebugLog("key=" .. k .. ", " .. "value=" .. v)
end

RGWDebugLog("number of tags is: " .. #Request.Tags)
for k, v in pairs(Request.Tags) do
  RGWDebugLog("key=" .. k .. ", " .. "value=" .. v)
end

if Request.Object then
  RGWDebugLog("number of object metadata entries is: " .. #Request.Object.Metadata)
  for k, v in pairs(Request.Object.Metadata) do
    RGWDebugLog("key=" .. k .. ", " .. "value=" .. v)
  end

  RGWDebugLog("number of object tags is: " .. #Request.Object.Tags)
  for k, v in pairs(Request.Object.Tags) do
    RGWDebugLog("key=" .. k .. ", " .. "value=" .. v)
  end
end
  • upload to postrequest context:
bin/radosgw-admin script put --infile postrequest.lua --context postrequest
  • create a bucket using the AWS CLI:
aws --endpoint-url http://localhost:8000 s3 mb s3://fish
  • create a random file:
head -c 12K /dev/urandom > sample.txt
  • upload the file to the bucket with custom metadata
aws --endpoint-url http://localhost:8000 s3 cp sample.txt s3://fish --metadata '{"hello": "world"}'
  • add tags to the file:
aws --endpoint-url http://localhost:8000 s3api put-object-tagging --bucket=fish --key='sample.txt' --tagging='{"TagSet": [{"Key": "hello", "Value": "world"}]}'
  • get the file back:
aws --endpoint-url http://localhost:8000 s3 cp s3://fish/sample.txt .
  • verify the metadata tags are printed to the log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment