Project

General

Profile

Bug #27654

Strange behavior of the S3 Get Bucket lifecycle when the Origin header is included in the request

Added by Beom-Seok Park over 5 years ago. Updated over 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

Steps to Reproduce
  1. Create a bucket.
  2. Request S3 Get Bucket lifecycle API with Origin header.

Actual results

<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchLifecycleConfiguration</Code><BucketName>bucketname</BucketName><RequestId>tx00000000000000000003b-005b83b71e-11cc-default</RequestId><HostId>11cc-default-default</HostId></Error><LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LifecycleConfiguration>

Expected results

<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchLifecycleConfiguration</Code><BucketName>bucketname</BucketName><RequestId>tx00000000000000000003c-005b83b72f-11cc-default</RequestId><HostId>11cc-default-default</HostId></Error>

It seems that the value of op_ret changed in end_header.
https://github.com/ceph/ceph/blob/luminous/src/rgw/rgw_rest_s3.cc#L2259

void RGWGetLC_ObjStore_S3::send_response()
{
  if (op_ret) {
    if (op_ret == -ENOENT) {    
      set_req_state_err(s, ERR_NO_SUCH_LC);
    } else {
      set_req_state_err(s, op_ret);
    }
  }
  dump_errno(s);
  end_header(s, this, "application/xml"); <-- op_ret value is changed here.
  dump_start(s);

  if (op_ret < 0)
    return;

  config.dump_xml(s->formatter);
  rgw_flush_formatter_and_reset(s, s->formatter);
}

History

#1 Updated by Casey Bodley over 5 years ago

  • Status changed from New to 12

thanks for tracking this down. can you suggest a fix?

#2 Updated by Beom-Seok Park over 5 years ago

I'm not sure if I fixed it correctly.
However, the responses of the following cases are correct.

diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index 3b07327..545e1f3 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -2251,6 +2251,10 @@ void RGWGetLC_ObjStore_S3::send_response()
   if (op_ret) {
     if (op_ret == -ENOENT) {
       set_req_state_err(s, ERR_NO_SUCH_LC);
+      dump_errno(s);
+      end_header(s, this, "application/xml");
+      dump_start(s);
+      return;
     } else {
       set_req_state_err(s, op_ret);
     }
  1. no lifecycle rule + no origin header
    <?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchLifecycleConfiguration</Code><BucketName>lctest</BucketName><RequestId>tx000000000000000000008-005b88a82d-122b8-default</RequestId><HostId>122b8-default-default</HostId></Error>
    
  2. no lifecycle rule + origin header
    <?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchLifecycleConfiguration</Code><BucketName>lctest</BucketName><RequestId>tx00000000000000000000a-005b88a894-122b8-default</RequestId><HostId>122b8-default-default</HostId></Error>
    
  3. lifecycle rule + no origin header
    <?xml version="1.0" encoding="UTF-8"?><LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>lifecycle_test</ID><Prefix></Prefix><Status>Enabled</Status><Expiration><Days>7</Days></Expiration></Rule></LifecycleConfiguration>
    
  4. lifecycle rule + origin header
    <?xml version="1.0" encoding="UTF-8"?><LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>lifecycle_test</ID><Prefix></Prefix><Status>Enabled</Status><Expiration><Days>7</Days></Expiration></Rule></LifecycleConfiguration>
    

#3 Updated by Abhishek Lekshmanan over 5 years ago

Can you create a PR with this changeset?

#4 Updated by Beom-Seok Park over 5 years ago

Abhishek Lekshmanan wrote:

Can you create a PR with this changeset?

PR
https://github.com/ceph/ceph/pull/24096

#5 Updated by Patrick Donnelly over 4 years ago

  • Status changed from 12 to New

#6 Updated by Beom-Seok Park over 4 years ago

@Patrick
My colleague created a new PR.
https://github.com/ceph/ceph/pull/28622

Also available in: Atom PDF