Skip to content

rgw/swift: preserve dashes/underscores in swift user metadata names - #50790

Merged
cbodley merged 4 commits into
ceph:mainfrom
jzhu116-bloomberg:wip-51772
Nov 24, 2023
Merged

cbodley merged 4 commits into
ceph:mainfrom
jzhu116-bloomberg:wip-51772

Conversation

@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor

Preserve dashes/underscores in swift user metadata names so it allows proper display and deletion.

Fixes: https://tracker.ceph.com/issues/51772
Signed-off-by: Jane Zhu [email protected]

Contribution Guidelines

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@jzhu116-bloomberg
jzhu116-bloomberg requested a review from a team as a code owner March 30, 2023 05:47
@github-actions github-actions Bot added the rgw label Mar 30, 2023
@cbodley

cbodley commented Mar 30, 2023

Copy link
Copy Markdown
Contributor

thanks @jzhu116-bloomberg! does this change the format of the stored RGW_ATTR_META_PREFIX xattrs? have you been able to verify that user metadata written before this fix can still be accessed/removed after upgrading to the fixed version?

@alimaredia
alimaredia self-requested a review March 30, 2023 15:53
@jzhu116-bloomberg

jzhu116-bloomberg commented Mar 31, 2023 •

Copy link
Copy Markdown
Contributor Author

thanks @jzhu116-bloomberg! does this change the format of the stored RGW_ATTR_META_PREFIX xattrs? have you been able to verify that user metadata written before this fix can still be accessed/removed after upgrading to the fixed version?

No, it doesn't change the format of the stored RGW_ATTR_META_PREFIX xattrs.
Here are some tests that I've done on both "Quincy 17.2.0" and the fixed version ("main + this PR").

After
$ swift -U test:tester -K testing -A http://xx.xx.xx.xx:8080/auth/1.0 post bucket -H X-Container-Meta-test_container_meta1:Meta1
$ swift -U test:tester -K testing -A http://xx.xx.xx.xx:8080/auth/1.0 post bucket -H X-Container-Meta-test-container-meta2:Meta2

On both "Quincy 17.2.0" and "main + this PR", I have the following format. They are exactly the same on both versions.
$ sudo rados -p dev-zone-bcc-master.rgw.meta -N root listxattr .bucket.meta.bucket:99e891b6-ee98-4625-bf42-acda8503bff0.5553.1
ceph.objclass.version
user.rgw.acl
user.rgw.x-amz-meta-test-container-meta2
user.rgw.x-amz-meta-test_container_meta1

I also tested retrieving/removing the metadata set in version "Quincy 17.2.0" after I upgraded my cluster to the version "main + this PR"), and everything worked well.

However please note, with the fixed version, there is a display change in the output of "stat bucket". Please see the following examples. In the fixed version, the output reflects exactly the dashes/underscores in the metadata names, instead of always converting them to dashes in the older versions.

On "Quincy 17.2.0",
$ swift -U test:tester -K testing -A http://xx.xx.xx.xx:8080/auth/1.0 stat bucket
...
Meta Test-Container-Meta2: Meta2
Meta Test-Container-Meta: Meta1
...

On "main + this PR",
$ swift -U test:tester -K testing -A http://xx.xx.xx.xx:8080/auth/1.0 stat bucket
...
Meta Test-Container-Meta2: Meta2
Meta Test_Container_Meta: Meta1
...

@mdw-at-linuxbox

Copy link
Copy Markdown
Contributor

Couple of code nits: /1/ you can glue std::strings together using +, and /2/ you can ingest r-values (& eventually return them as your result) using "&&". Using both of these should produce simpler better code. (yes the original code didn't do that...) { there's a stringstream use & an on-stack variable C string allocation that I think you can eliminate with this... { and yes your stringstream is better than the original code snprintf...} }

Also, /3/ rather than having two slightly different copies of the lowercase-dash and camelcase-http functions I'd recommend adding an extra boolean flag to elicit the different behavior. You can add a 'default' value for the parameter in .h if you only want the special behavior in a few places.

@alimaredia

alimaredia commented Jul 27, 2023 •

Copy link
Copy Markdown
Contributor

@mattbenjamin

Copy link
Copy Markdown
Contributor

agree, avoid stringstream if possible, maybe fmt can substitute?

@cbodley

cbodley commented Aug 3, 2023

Copy link
Copy Markdown
Contributor

i just recently noticed that the swift API specifies that underscores should be converted to dashes:

Note: Metadata keys (the name of the metadata) must be treated as case-insensitive at all times. These keys can contain ASCII 7-bit characters that are not control (0-31) characters, DEL, or a separator character, according to HTTP/1.1. The underscore character is silently converted to a hyphen.

this text shows up under both https://docs.openstack.org/api-ref/object-store/#create-container and https://docs.openstack.org/api-ref/object-store/#create-update-or-delete-container-metadata

tempest test case test_create_container_with_metadata_value checks for this part and is failing with this PR

we used to handle this correctly for swift before #38737, which was a fix for the s3 side; however, those changes should have only applied to the s3 API

@jzhu116-bloomberg
jzhu116-bloomberg force-pushed the wip-51772 branch 2 times, most recently from dff0b53 to c5e24a4 Compare August 8, 2023 14:09
@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor Author

Checked in changes

  • based on code review
  • to convert underscores to hyphens for swift metadata
  • to allow deleting of the existing metadata

@prazumovsky

Copy link
Copy Markdown

Just to note: Quincy has the same issue so the potential backport required after https://tracker.ceph.com/issues/51772 will be fixed.

@prazumovsky

Copy link
Copy Markdown

Do we have any updates on this issue? We disabled corresponding tempest tests but want to see them working with a proper fix

@alimaredia

Copy link
Copy Markdown
Contributor

@prazumovsky: When I run this PR through the tempests tests locally I still get failures for tempest.api.object_storage.test_container_services.ContainerTest.test_create_container_with_remove_metadata_.*'.

I have a an additional fix (ceph/ceph-ci@3999c57) that got the tests to pass locally. I want to run it through the tempest tests in teuthology before it is added to this PR. I should have more information in the next day or two.

@prazumovsky

Copy link
Copy Markdown

thank you for the update!

@alimaredia

Copy link
Copy Markdown
Contributor

@jzhu116-bloomberg @cbodley updated this PR with a commit that has the tempest tests passing. Will need someone else to review.

Comment thread src/rgw/rgw_op.cc Outdated
Comment on lines 3436 to 3597

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed in the bug scrub - we want to return here on any fatal errors, but continue on if op_ret is either EEXIST or ERR_BUCKET_EXISTS

Comment thread src/rgw/rgw_op.cc Outdated

@cbodley cbodley Sep 22, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (op_ret < 0 && op_ret != -EEXIST && op_ret != -ERR_BUCKET_EXISTS)

@cbodley cbodley self-assigned this Oct 19, 2023
@cbodley

cbodley commented Oct 31, 2023

Copy link
Copy Markdown
Contributor

@cbodley cbodley removed the needs-qa label Oct 31, 2023
@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor Author

@alimaredia please use public links: http://pulpito.ceph.com/amaredia-2023-10-30_21:38:22-rgw-wip-rgw-swift-preserve-dash-underscore-in-container-metadata-distro-default-smithi/

i see the relevent tempest tests are failing [teuthology.log]: tempest.api.object_storage.test_container_services.ContainerTest.test_create_container_with_remove_metadata_key tempest.api.object_storage.test_container_services.ContainerTest.test_create_container_with_remove_metadata_value

I did some more manual tests, and found out that POST request works fine, but not PUT request. The above 2 tempest tests are using PUT requests.

The very first PUT request to create a container with "X-Container-Meta-*" header succeeds with status code 201, and the meta data is properly set. However the following PUT requests on the same container return with the status code 202 without handling the "X-Container-Meta-*"/"X-Remove-Container-Meta-*" headers at all.

Please see below for some relevant log lines:
The 1st PUT request:

...
2023-11-01T03:25:59.513+0000 7f1798870700 20 HTTP_X_CONTAINER_META_TEST_CONTAINER_META=Meta1   
2023-11-01T03:25:59.513+0000 7f1798870700 20 REQUEST_METHOD=PUT                        
...
2023-11-01T03:25:59.513+0000 7f1798870700  1 ====== starting new request req=0x7f1696e6c790 =====
...
2023-11-01T03:25:59.518+0000 7f1794868700 10 req 17953498483730442036 0.005000074s swift:create_bucket x>> x-amz-meta-test-container-meta:Meta1
2023-11-01T03:25:59.518+0000 7f1794868700 10 req 17953498483730442036 0.005000074s swift:create_bucket user=test bucket=:bucket3[])
2023-11-01T03:25:59.518+0000 7f1794868700 10 req 17953498483730442036 0.005000074s swift:create_bucket cache get: name=default.rgw.meta+root+bucket3 : hit (negative entry)
...
2023-11-01T03:25:59.560+0000 7f178e05b700 20 req 17953498483730442036 0.047000695s swift:create_bucket rgw_create_bucket returned ret=0 bucket=:bucket3[43eefdcb-0adb-4c1d-9ce2-63ce3f37d3c9.4279.4])

2023-11-01T03:25:59.560+0000 7f178e05b700  2 req 17953498483730442036 0.047000695s swift:create_bucket completing
2023-11-01T03:25:59.560+0000 7f178e05b700 10 req 17953498483730442036 0.047000695s cache get: name=default.rgw.log++script.postrequest. : hit (negative entry)
2023-11-01T03:25:59.560+0000 7f178e05b700  2 req 17953498483730442036 0.047000695s swift:create_bucket op status=1900
2023-11-01T03:25:59.560+0000 7f178e05b700  2 req 17953498483730442036 0.047000695s swift:create_bucket http status=201
2023-11-01T03:25:59.560+0000 7f178e05b700  1 ====== req done req=0x7f1696e6c790 op status=1900 http_status=201 latency=0.047000695s ======  

The 2nd PUT request on the same container:

...                                                               
2023-11-01T03:25:59.566+0000 7f1792864700 20 HTTP_X_CONTAINER_META_TEST_CONTAINER_META=Meta2
2023-11-01T03:25:59.566+0000 7f1792864700 20 REQUEST_METHOD=PUT                           
...                                                          
2023-11-01T03:25:59.566+0000 7f1792864700  1 ====== starting new request req=0x7f1696e6c790 =====  
...
2023-11-01T03:25:59.568+0000 7f178684c700 10 req 14590071125625771467 0.002000030s swift:create_bucket x>> x-amz-meta-test-container-meta:Meta2
2023-11-01T03:25:59.568+0000 7f178684c700 10 req 14590071125625771467 0.002000030s swift:create_bucket user=test bucket=:bucket3[])
2023-11-01T03:25:59.568+0000 7f178684c700 10 req 14590071125625771467 0.002000030s swift:create_bucket cache get: name=default.rgw.meta+root+bucket3 : hit (requested=0x11, cached=0x17)
...
2023-11-01T03:25:59.575+0000 7f178b055700 20 req 14590071125625771467 0.009000134s swift:create_bucket rgw_create_bucket returned ret=-2013 bucket=:bucket3[43eefdcb-0adb-4c1d-9ce2-63ce3f37d3c9.4279.4])
2023-11-01T03:25:59.575+0000 7f178b055700  2 req 14590071125625771467 0.009000134s swift:create_bucket completing
2023-11-01T03:25:59.575+0000 7f178b055700 10 req 14590071125625771467 0.009000134s cache get: name=default.rgw.log++script.postrequest. : hit (negative entry)
2023-11-01T03:25:59.575+0000 7f178b055700  2 req 14590071125625771467 0.009000134s swift:create_bucket op status=1901
2023-11-01T03:25:59.575+0000 7f178b055700  2 req 14590071125625771467 0.009000134s swift:create_bucket http status=202
2023-11-01T03:25:59.576+0000 7f178b055700  1 ====== req done req=0x7f1696e6c790 op status=1901 http_status=202 latency=0.010000148s ======

What should be the correct behavior for a PUT request on an existing container in terms of custom metadata handling?
I see the following text in https://docs.openstack.org/api-ref/object-store/#create-container

You do not need to check whether a container already exists before issuing a PUT operation because the operation is idempotent: It creates a container or updates an existing container, as appropriate.

Does this mean we should update all attributes specified in the PUT container request if the container exists?

@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor Author

Does this mean we should update all attributes specified in the PUT container request if the container exists?

Please ignore my question. I didn't read through thoroughly. Ali's fix actually answered it.
This doesn't work however. Somewhere else is wrong.

Comment thread src/rgw/rgw_op.cc Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be if (op_ret < 0 && op_ret != -EEXIST && op_ret != -ERR_BUCKET_EXISTS) ?

@github-actions

github-actions Bot commented Nov 8, 2023

Copy link
Copy Markdown

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

@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@jzhu116-bloomberg

Copy link
Copy Markdown
Contributor Author

jenkins test api

@alimaredia

Copy link
Copy Markdown
Contributor

jenkins test api

@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

@prazumovsky

Copy link
Copy Markdown

Please actualizethis PR because the issue is still reproducable

@cbodley

cbodley commented Nov 23, 2023

Copy link
Copy Markdown
Contributor

pushed a rebase that removed the merge commit. the tasks/tempest.yaml conflict was resolved automatically. will merge once checks pass

@prazumovsky

Copy link
Copy Markdown

Bugfix merged, great news! Hope to see it in reef and quincy.

@prazumovsky

prazumovsky commented Apr 1, 2024 •

Copy link
Copy Markdown

@jzhu116-bloomberg @cbodley

Hello! Still hoping to see backport to Reef at least :)


UPD
Ok, I did it by myself:
reef: #56615
quincy: #56616

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.

6 participants