Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw : add the check for bucket handler if http args exist object_exclusive sub_resource #38741

Merged
merged 1 commit into from Mar 4, 2021

Conversation

BryceCao
Copy link
Contributor

Fixes: https://tracker.ceph.com/issues/48727
Signed-off-by: caolei halei15848934852@163.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

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 api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@github-actions github-actions bot added the rgw label Dec 31, 2020
@BryceCao
Copy link
Contributor Author

i check all over the sub_resource of bucket and object, "append", "torrent", "uploadId","uploads", "partNumber", "versionId" are object_exclusive, and "cors","notification","location","logging","lifecycle","delete","versions","versioning","website","requestPayment","position","policyStatus","publicAccessBlock" are bucket_exclusive , "acl", "tagging" are shared. So the nonstandard request wont pass.

@@ -4878,7 +4878,7 @@ RGWHandler_REST* RGWRESTMgr_S3::get_handler(rgw::sal::RGWRadosStore *store,
} else {
if (s->init_state.url_bucket.empty()) {
handler = new RGWHandler_REST_Service_S3(auth_registry, enable_sts, enable_iam, enable_pubsub);
} else if (rgw::sal::RGWObject::empty(s->object.get())) {
} else if (rgw::sal::RGWObject::empty(s->object.get()) && !s->info.args.exist_obj_excl_sub_resource()) {
Copy link
Contributor

@dang dang Jan 7, 2021

Choose a reason for hiding this comment

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

This is the right idea, I think, but I don't think we want to dispatch into the object handler if we have no object. How about re-arranging it so it looks like this:

if (!object.empty()) {
    handler = object_hander;
} else if (exist_obj_excl_sub_resource()) {
    return NULL;
} else {
    handler = bucket_handler;
}

bool exist_obj_excl_sub_resource() const {
char* obj_sub_resource[] = {"append", "torrent", "uploadId",
"uploads", "partNumber", "versionId"};
for (int i = 0; i != 6; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

6 should be obj_sub_resource.size()

@BryceCao BryceCao force-pushed the wip-standardize-request branch 3 times, most recently from acfd483 to b7b0cd6 Compare January 8, 2021 05:50
@BryceCao
Copy link
Contributor Author

BryceCao commented Jan 8, 2021

@dang Thx, it would be unsafe and Inefficient to dispatch into the object handler when object is empty, i hava corrected the code.

@BryceCao
Copy link
Contributor Author

BryceCao commented Jan 8, 2021

@ofriedma thank you for advance in code elegance. this part has been modified.

@ofriedma
Copy link
Contributor

@BryceCao
One last thing sorry I didn't mention can you please add comment near the complete sub resource (not yours) comment that if someone adds new object sub resource, it should be added to the new structure too.
Other than that LGTM

@BryceCao
Copy link
Contributor Author

@ofriedma comment has been added.

@cbodley
Copy link
Contributor

cbodley commented Jan 29, 2021

this appears to be failing test_list_multipart_upload:

======================================================================
ERROR: s3tests_boto3.functional.test_s3.test_list_multipart_upload
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ubuntu/cephtest/s3-tests/s3tests_boto3/functional/test_s3.py", line 7244, in test_list_multipart_upload
    response = client.list_multipart_uploads(Bucket=bucket_name)
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (MethodNotAllowed) when calling the ListMultipartUploads operation: Unknown
-------------------- >> begin captured logging << --------------------

?uploads is a bucket resource, isn't it?

@BryceCao
Copy link
Contributor Author

this appears to be failing test_list_multipart_upload:

======================================================================
ERROR: s3tests_boto3.functional.test_s3.test_list_multipart_upload
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ubuntu/cephtest/s3-tests/s3tests_boto3/functional/test_s3.py", line 7244, in test_list_multipart_upload
    response = client.list_multipart_uploads(Bucket=bucket_name)
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/ubuntu/cephtest/s3-tests/virtualenv/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (MethodNotAllowed) when calling the ListMultipartUploads operation: Unknown
-------------------- >> begin captured logging << --------------------

?uploads is a bucket resource, isn't it?

Oh, I made a mistake here. ?uploads is a shared resource, because 'POST /{Key}?uploads' can create a MultipartUpload.

…usive sub_resource

Fixes: https://tracker.ceph.com/issues/48727
Signed-off-by: caolei <halei15848934852@163.com>
@harishmunjulur harishmunjulur merged commit 9d15a4e into ceph:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants