Repository navigation
Conversation
|
Overall looks fine. Pointing out that this PR does not address HEAD ops. For example, there is no HEAD op for Bucket Inventory Configuration in the AWS docs (https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html) and therefore a HEAD op called on a bucket with this subresource falls back to RGWStatBucket. This is low risk and does not result in data loss, but still returns incorrect information instead of returning 405/400 (https://docs.aws.amazon.com/AmazonS3/latest/developerguide/ErrorResponses.html). So we need to decide if we can take this as is and have a follow up PR for HEAD ops later. Also splitting out the tests related to this PR in ceph/s3-tests#763 into a separate PR of its own, might help in merging this PR faster. |
| if (const char* api = unimplemented_api(s, unimplemented_bucket_apis); api) { | ||
| ldpp_dout(s, 5) << "the bucket sub-resource " << api << " names an S3 API " | ||
| "that rgw does not implement" << dendl; | ||
| return -ERR_NOT_IMPLEMENTED; |
There was a problem hiding this comment.
not sure 501 Not Implemented is what we really want here.. from https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/501
501 is the appropriate response when the server does not recognize the request method and is incapable of supporting it for any resource. Servers are required to support GET and HEAD, and therefore must not return 501 in response to requests with these methods. If the server does recognize the method, but intentionally does not allow it, the appropriate response is 405 Method Not Allowed.
we handle existing subresources in RGWOp factory functions like RGWHandler_REST_Bucket_S3::op_options(), RGWHandler_REST_Obj_S3::op_get(), etc. and returning nullptr maps to that http error 405 Method Not Allowed
for example in RGWHandler_REST_Obj_S3::op_get(),
} else if (is_obj_legal_hold_op()) {
return new RGWGetObjLegalHold_ObjStore_S3;
- }
+ } else if (const char* api = unimplemented_api(s, unimplemented_object_apis); api) {
+ ldpp_dout(s, 5) << "the object sub-resource " << api << " names an S3 API "
+ "that rgw does not implement" << dendl;
+ return nullptr;
+ }
return get_obj_op(true);
}There was a problem hiding this comment.
There is some precedent in AWS. If you send a request with x-amz-expected-bucket-owner against a directory bucket, you will get a 501 - a header that was provided implies functionality that is not implemented.
If a sub-resource API is not supported by an endpoint, like a GET or PUT '/?accelerate' against a bucket in a region that doesn't support Transfer Acceleration, that results in a 405. So given this, I think I'd agree with you, it should be a 405 for API actions that we do not support.
I'll move the check into op_* factories and return the nullptr, and update the tests to expect 405.
There was a problem hiding this comment.
Done in the latest push. The check is now an is_unimplemented_op() test in op_get(), op_put(), op_delete() and op_post() of the bucket and object handlers, placed after the sub-resources each method serves, and it returns nullptr for a 405. The init() overrides are gone.
The tests are in the second commit, under src/test/rgw/s3-tests, and expect 405 MethodNotAllowed. On a vstart cluster all 18 cases fail without the fix and pass with it.
we moved s3-tests into the ceph repo under src/test/rgw/s3-tests, so ceph prs need to include their own tests now. it's probably time to archive the s3-tests repo |
The op_*() methods of the S3 bucket and object handlers test the sub-resources they serve, and run any other request as the plain bucket or object operation for its method. A request for an S3 API that rgw lacks therefore runs as another operation, and is answered success: - DeleteBucketMetricsConfiguration and the other configuration deletes for analytics, inventory, intelligent-tiering and metadata tables run as DeleteBucket, and delete an empty bucket. - PutObjectAnnotation and UpdateObjectEncryption run as PutObject, and replace the object's data with the request body. RenameObject runs as PutObject with no body, and leaves an empty object at the destination. - DeleteObjectAnnotation runs as DeleteObject, and deletes the object. - The Get and List calls run as ListObjects or GetObject. ceph#46263 fixed this for DeleteBucketEncryption and DeleteBucketReplication by serving those sub-resources; each API that S3 has added since falls through the same way. Return no op for a request whose query names one of these APIs' sub-resources and none that its method serves, which is answered 405 MethodNotAllowed. S3 answers the same for a sub-resource that a region does not serve, such as accelerate, and S3 clients read it as a feature the endpoint lacks. The test is in the op_get(), op_put(), op_delete() and op_post() methods of the S3 bucket and object handlers, so it does not apply to the S3 website handlers, whose query strings are the site's. HEAD and OPTIONS requests are left alone. Fixes: https://tracker.ceph.com/issues/80921 Assisted-by: Claude:claude-opus-5-5 Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Kyle Bader <[email protected]>
A call to an S3 API that rgw lacks ran as the plain bucket or object operation for its method, and was answered success. An implementation that lacks an API refuses it and changes nothing. These tests make sure that the bucket or object survives the call, on any implementation: - test_bucket_config_delete_keeps_bucket, for the metrics, analytics, inventory and intelligent-tiering configurations: rgw deleted the bucket. - test_object_annotation_put_keeps_object and test_update_object_encryption_keeps_data: rgw replaced the object's data with the request body. - test_object_annotation_delete_keeps_object: rgw deleted the object. - test_rename_object_keeps_destination: rgw answered success and left an empty object at the destination. - test_bucket_metrics_configuration_get_unconfigured: rgw answered 200 with a bucket listing. Three more test rgw's own answer, and do not apply to AWS, which serves these APIs: - test_unimplemented_api_method_not_allowed: each method of a sub-resource that rgw does not serve is answered 405 MethodNotAllowed. - test_unimplemented_api_versioned_ok and its _suspended variant: the tagging, ACL, HEAD and ListObjectVersions requests that carry a version id still work in a versioned bucket. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Kyle Bader <[email protected]>
a1fad0b to
8bc23c6
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
| // DeleteObject, and be answered success. They return no op for one instead, | ||
| // which is answered 405 MethodNotAllowed, as S3 answers for a sub-resource | ||
| // that a region does not serve. | ||
| static constexpr const char* unimplemented_bucket_apis[] = { |
There was a problem hiding this comment.
any suggestions for how we could keep these lists updated as aws adds more subresources? this will continue to be a problem in the future
if the risk of data loss is particularly high for the DELETE method, maybe we could add extra logic to reject those specific requests on any unrecognized query params. DeleteBucket doesn't specify any, and DeleteObject only specifies ?versionId
we might also cover the PUT method in CreateBucket and PutObject, neither of which specify any query params
There was a problem hiding this comment.
note that multisite does add some query params starting with RGW_SYS_PARAM_PREFIX that we shouldn't reject
A request for an S3 API that rgw does not implement is not refused. The op_*() methods of the S3 bucket and object handlers test the sub-resources they serve, and run any other request as the plain bucket or object operation for its method, answering success:
Tools that manage bucket configuration, such as Terraform, call the configuration deletes when they remove one. #46263 fixed this for DeleteBucketEncryption and DeleteBucketReplication by serving those sub-resources; each API added to S3 since then falls through the same way.
This refuses a request whose query names one of these APIs' sub-resources with 501 NotImplemented, which S3 clients read as a feature the endpoint lacks. The list comes from AWS's Smithy model of S3. The check is in the init() of the S3 bucket and object handlers, so the S3 website handlers, whose query strings belong to the site, are unaffected; HEAD and OPTIONS requests are left alone. The GET calls, which answered a bucket listing, now answer 501 too.
Fixes: https://tracker.ceph.com/issues/80921
Validated on a single-host vstart cluster: the s3-tests reproducers test_bucket_config_delete_keeps_bucket (metrics, analytics, inventory, intelligent-tiering), test_object_annotation_put_keeps_object, test_object_annotation_delete_keeps_object, test_update_object_encryption_keeps_data, test_rename_object_keeps_destination and test_bucket_metrics_configuration_get_unconfigured (ceph/s3-tests#763) fail on main and pass with this change, and test_s3.py as the rgw suite runs it shows no new failures.
Versioned buckets
None of the refused subresources is used by versioned requests. s3-tests
test_unimplemented_api_versioned_okand_suspendedcheck that tagging, ACL, HEAD and ListObjectVersions requests with a version id still work, and that a refused subresource answers 501.Checklist