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/swift: fix updating metadata failed for swift CORS #10411
Conversation
I found it doesn't work when I try to update the CORS metadata of swift buckets. as the following steps: 1) using the following command to create a swift bucket and post the CORS metadata; `swift post swiftbkt0011 -H "X-Container-Meta-Access-Control-Allow-Origin: http://192.9.9.22" -H "X-Container-Meta-Access-Control-Request-Method: HEAD,POST,PUT,GET,OPTIONS,DELETE"` 2) using the command to update the `Access-Control-Allow-Origin` attr; `swift post swiftbkt0011 -H "X-Container-Meta-Access-Control-Allow-Origin: http://192.9.9.130" -H "X-Container-Meta-Access-Control-Request-Method: HEAD,POST,PUT,GET,OPTIONS,DELETE"` 3) test the CORS, access my swift bucket `swiftbkt0011` from the website at `192.9.9.130` then I got the following failed log message: `2016-07-09 16:49:14.070218 7f6be3fef700 15 Read RGWCORSConfiguration<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><CORSRule><AllowedMethod>GET</AllowedMethod><AllowedMethod>PUT</AllowedMethod><AllowedMethod>DELETE</AllowedMethod><AllowedMethod>HEAD</AllowedMethod><AllowedMethod>POST</AllowedMethod><AllowedMethod>COPY</AllowedMethod><AllowedOrigin>http://192.9.9.22</AllowedOrigin></CORSRule></CORSConfiguration> 2016-07-09 16:49:14.070300 7f6be3fef700 10 There is no cors rule present for http://192.9.9.130` the `AllowedOrigin` has not yet update, so maybe we should not use `emplace` which will not update the attrs if they are already present in attrs. Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
@@ -3130,7 +3130,7 @@ void RGWPutMetadataBucket::execute() | |||
if (has_cors) { | |||
buffer::list bl; | |||
cors_config.encode(bl); | |||
emplace_attr(RGW_ATTR_CORS, std::move(bl)); | |||
attrs[RGW_ATTR_CORS] = std::move(bl); |
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 is a bit surprising. From the code I can deduce the assumption that RGW_ATTR_CORS
(and its current value from the RADOS store) shouldn't be present in RGWPutMetadataBucket::attrs
at this phase. I need to debug this further.
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.
@rzarzynski thanks, yeh, I have tested this as the steps mentioned above and it worked as expected.
@Yan-waller: I can't replicate the issue on my FormPost branch that bases on 99bb2f3 (quite fresh
Let's do the extra check with the address the bucket was created initially:
Actually it seems to work as expected. We had very similar problem in the past. It has been fixed in #9263. Are sure you tested on the patched version? |
The cleanup commit has been merged in #11292. Closing this PR as it looks that the bug is already fixed. |
I found it doesn't work when I try to update the CORS metadata
of swift buckets. as the following steps:
use the following command to create a swift bucket and post the CORS metadata;
swift post swiftbkt0011 -H "X-Container-Meta-Access-Control-Allow-Origin: http://192.9.9.22" -H "X-Container-Meta-Access-Control-Request-Method: HEAD,POST,PUT,GET,OPTIONS,DELETE"
use the command to update the
Access-Control-Allow-Origin
attr;swift post swiftbkt0011 -H "X-Container-Meta-Access-Control-Allow-Origin: http://192.9.9.130" -H "X-Container-Meta-Access-Control-Request-Method: HEAD,POST,PUT,GET,OPTIONS,DELETE"
test the CORS, access my swift bucket
swiftbkt0011
from the website at192.9.9.130
then I got the following failed log message:
the
AllowedOrigin
has not yet update(stillhttp://192.9.9.22
), so maybe we should notuse
emplace
which will not update the attrs if they are already present in attrs.Signed-off-by: Yan Jun yan.jun8@zte.com.cn