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: Admin API Support for bucket quota change #18324

Merged
merged 3 commits into from Jan 5, 2018

Conversation

Jeegn-Chen
Copy link
Contributor

Allow admin to change the quota of a individual bucket through Admin API

Fixes: http://tracker.ceph.com/issues/21811
Signed-off-by: Jeegn Chen jeegnchen@gmail.com

@Jeegn-Chen
Copy link
Contributor Author

Here are the examples of API calls

host=127.0.0.1:8000
resource="/admin/bucket"
param="?format=json&bucket=test-a&quota&uid=testid"
contentType="application/json"
dateValue=$(date -R -u)
stringToSign="PUT

${contentType}
${dateValue}
${resource}"
s3Key=ABCDEFGHIJKLMNOPQRST
s3Secret='abcdefghijklmnopqrstuvwxyzabcdefghijklmn'
signature=$(/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64)
curl -v -X PUT \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  http://${host}${resource}${param} -d '{
        "enabled": true,
        "max_objects": 1,
        "max_size_kb": 5
    }'
host=127.0.0.1:8000
resource="/admin/bucket"
param="?format=json&bucket=test-a&quota&uid=testid"
contentType="application/json"
dateValue=$(date -R -u)
stringToSign="PUT

${contentType}
${dateValue}
${resource}"
s3Key=ABCDEFGHIJKLMNOPQRST
s3Secret='abcdefghijklmnopqrstuvwxyzabcdefghijklmn'
signature=$(/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64)
curl -v -X PUT \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  "http://${host}${resource}${param}&enabled=false"
host=127.0.0.1:8000
resource="/admin/bucket"
param="?format=json&bucket=test-a&quota&uid=testid"
contentType="application/json"
dateValue=$(date -R -u)
stringToSign="PUT

${contentType}
${dateValue}
${resource}"
s3Key=ABCDEFGHIJKLMNOPQRST
s3Secret='abcdefghijklmnopqrstuvwxyzabcdefghijklmn'
signature=$(/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64)
curl -v -X PUT \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  "http://${host}${resource}${param}&max-objects=2"
host=127.0.0.1:8000
resource="/admin/bucket"
param="?format=json&bucket=test-a&quota&uid=testid"
contentType="application/json"
dateValue=$(date -R -u)
stringToSign="PUT

${contentType}
${dateValue}
${resource}"
s3Key=ABCDEFGHIJKLMNOPQRST
s3Secret='abcdefghijklmnopqrstuvwxyzabcdefghijklmn'
signature=$(/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64)
curl -v -X PUT \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  "http://${host}${resource}${param}&max-size-kb=10"
host=127.0.0.1:8000
resource="/admin/bucket"
param="?format=json&bucket=test-a&quota&uid=testid"
contentType="application/json"
dateValue=$(date -R -u)
stringToSign="PUT

${contentType}
${dateValue}
${resource}"
s3Key=ABCDEFGHIJKLMNOPQRST
s3Secret='abcdefghijklmnopqrstuvwxyzabcdefghijklmn'
signature=$(/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64)
curl -v -X PUT \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  "http://${host}${resource}${param}&max-size-kb=100&max-objects=101&enabled=true"

dang
dang previously approved these changes Oct 16, 2017
@Jeegn-Chen
Copy link
Contributor Author

@yuriw Could you take a look at this PR?

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

10 similar comments
@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

@yuriw
Copy link
Contributor

yuriw commented Dec 12, 2017

}

bucket_info.quota = op_state.quota;
r = store->put_bucket_instance_info(bucket_info, false, real_time(), &attrs);
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamemerson do you think this would be a good candidate for retry_raced_bucket_write()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment. I will take a look

@cbodley
Copy link
Contributor

cbodley commented Dec 15, 2017

@Jeegn-Chen i like the RGWBucketAdminOp::set_quota() stuff you added, so I'd like to find a way to keep using it along with retry_raced_bucket_write(). it looks like its req_state argument makes that difficult though. we might need to change its signature to something more general, like:

int retry_raced_bucket_write(RGWRados* g, RGWBucketInfo& info,
                             std::map<std::string, bufferlist> *pattrs, const F& f)

i'd also like to find a way to share more of this quota admin code between the rest api and the radosgw-admin quota commands, but that's probably out of scope for this pr

src/rgw/rgw_op.h Outdated
}
return r;
}
}
Copy link
Contributor

@cbodley cbodley Dec 15, 2017

Choose a reason for hiding this comment

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

since this helper is specific to buckets, i think rgw_bucket.h is a better home for it. also, since it's being moved into a header file, it shouldn't be wrapped in an anonymous namespace - so either remove that, or use namespace rgw instead

p.s. the PS comment isn't necessary! the git history is enough of a paper trail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbodley
So maybe it is better for me to remove the commit 'rgw: Leverage retry_raced_bucket_write when updating quota' from this PR and let's address retry_raced_bucket_write signature improvement in an independent PR for better commit isolation. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

works for me 👍

@Jeegn-Chen
Copy link
Contributor Author

Per discuss with @cbodley, remove the commit related to retry_raced_bucket_write, which is out of the scope of this PR and will be addressed in a separate one.

@yuriw
Copy link
Contributor

yuriw commented Dec 18, 2017

ready for merge

@cbodley
Copy link
Contributor

cbodley commented Jan 2, 2018

@Jeegn-Chen would you be willing to add a bit of documentation to doc/radosgw/adminops.rst for this new api?

@Jeegn-Chen
Copy link
Contributor Author

@cbodley Sure

Allow admin to change the quota of a individual bucket through Admin API

Fixes: http://tracker.ceph.com/issues/21811
Signed-off-by: Jeegn Chen <jeegnchen@gmail.com>
Allow admin to change the quota of a individual bucket through Admin API
with params in URL

Fixes: http://tracker.ceph.com/issues/21811
Signed-off-by: Jeegn Chen <jeegnchen@gmail.com>
@Jeegn-Chen
Copy link
Contributor Author

@cbodley I've just updated adminops.rst

@cbodley
Copy link
Contributor

cbodley commented Jan 4, 2018

thanks @Jeegn-Chen! the docs build has a minor complaint:

Warning, treated as error:
/home/jenkins-build/build/workspace/ceph-pr-docs/doc/radosgw/adminops.rst:1917: (WARNING/2) Title underline too short.

Set Quota for an Individual Bucket
~~~~~~~~~~~~~~~

Add usage doc for a new Admin API for individual bucket quota management

Fixes: http://tracker.ceph.com/issues/21811
Signed-off-by: Jeegn Chen <jeegnchen@gmail.com>
@Jeegn-Chen
Copy link
Contributor Author

@cbodley Sorry for not double checking the doc build. The issue should be fixed now.

@cbodley cbodley merged commit b99dae0 into ceph:master Jan 5, 2018
@hrchu
Copy link
Contributor

hrchu commented Jun 4, 2019

@cbodley

It's weird that:

pic

@cbodley
Copy link
Contributor

cbodley commented Jun 4, 2019

hi @hrchu, this work was backported to luminous in #20885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants