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: Fix incorrect content length and range for zero sized objects during range requests #10207
Conversation
@yehudasa can you please help review |
This fixes the content-length header but the content-range is still not correct |
That's true, should the range be 0-0/0 as well? |
it should be: |
I guess you meant that to be whatever user specifies as the range? Thinking through this, wouldn't any range be irrelevant for zero sized objects? |
We need to respond with 416 (Range Not Satisfiable) and |
@prallabh , Lets return 416 and remove the content-range header . I think this will be the simplest |
@oritwas Thanks for the link, wasn't aware of it. Realized that we were returning 416 else where as well in the code, was in the process of building the content-range for this case. If we do not bother about the range header, will update the commit with just the content length and 416. |
@oritwas I ended up fixing the range header as per the RFC, please take a look at the same. |
Here is what Amazon S3 gives (yes, 416):
|
I also wondering why you guys have travis "build", but don't write tests. Different condition-branch for handling zero is something tests designed for. |
@vsespb we don't have travis build yet (but yes, we could). why do you say so? |
ok, jenkins, not travis. |
@oritwas ping |
lgtm, but it need more testing. |
Thanks, do you mean to add a test under https://github.com/ceph/s3-tests. Have never done that, any pointers/documentation around best practices for that would help. |
@oritwas I have verified the fix with swift/s3 clients, can you please clarify on the test that you were referring to. |
I add a test to s3 tests for an empty object see ceph/s3-tests#119 could you try it an see if it passes? |
Thanks for the test, find below the result: S3TEST_CONF=range.conf ./virtualenv/bin/nosetests s3tests.functional.test_s3:test_ranged_request_empty_object .Ran 1 test in 0.568s OK |
@oritwas rebased. |
@oritwas ping |
@oritwas Realized that having the object size check in the Read::prepare would break while preforming operations like stat/download on a empty object (without a hint that the operation is a range request). Moved the checks ahead to RGWGetObj::execute where they should really be IMO. Please take a look, thanks! |
@prallabh can you rebase? |
@oritwas done |
@oritwas please let me know if there is anything pending from my side for merge. |
@@ -655,7 +655,9 @@ void end_header(struct req_state* s, RGWOp* op, const char *content_type, | |||
s->formatter->close_section(); | |||
} | |||
s->formatter->output_footer(); | |||
dump_content_length(s, s->formatter->get_len()); | |||
if (s->obj_size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to effect all error response and some require content-length. is it a problem to keep the content-length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content length here is that of the end header's and its not relevant in this context (I guess that should be true for all zero sized responses). For range requests on zero sized objects, without suppressing this header, the output looks something like this:
HTTP/1.1 416 Requested Range Not Satisfiable
Content-Range: bytes */0
Content-Length: 0
Accept-Ranges: bytes
X-Trans-Id: tx000000000000000000026-00579f3001-1011-default
Content-Length: 12
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Date: Mon, 01 Aug 2016 11:18:25 GMT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have here two content lengths headers,
it is because you add the content length even in case of an error see my comment on rgw_rest_swift.cc
As both swift or AWS are not returning a content-range header in case of such error, we can do the same. |
@oritwas Thanks, can you please check now if that is what you are expecting. |
dump_content_length(s, total_len); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit : extra empty line
other wise looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks!
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
@oritwas updated and rebased, please help merge. |
looks good |
Fixes: http://tracker.ceph.com/issues/16388
Signed-off-by: Pavan Rallabhandi PRallabhandi@walmartlabs.com