Skip to content

rgw: read user usage log in S3 GetUsage - #69459

Merged
AliMasarweh merged 8 commits into
ceph:mainfrom
RaminNietzsche:rgw-fix-getusage-user-read-usage
Aug 17, 2026
Merged

AliMasarweh merged 8 commits into
ceph:mainfrom
RaminNietzsche:rgw-fix-getusage-user-read-usage

Conversation

@RaminNietzsche

Copy link
Copy Markdown
Member

Summary

Hi! This PR fixes a long-standing gap in Ceph’s S3 extension GET /?usage.

The problem: When you call GET /?usage (no bucket in the URL), RGW only
read the usage log if s->bucket was set — which it isn’t for this
service-level request. So Entries (per-op stats like put_obj, get_obj)
stayed empty even with rgw enable usage log = true. You still got storage
info (CapacityUsed, Summary.TotalBytes), but the ops side looked broken.

The fix: In RGWGetUsage::execute(), when there’s no bucket in the URL,
read usage from the authenticated user (s->user->read_usage()), same idea
as radosgw-admin usage show.

On top of the code fix, this PR also:

  • QA — extends the existing radosgw-admin teuthology task to call
    GET /?usage after usage data is flushed, fixes SigV4 signing for that
    request, and adds stronger checks (owner, Summary ops, TotalBytes).
  • boto3 — updates service-2.sdk-extras.json so get_usage_stats()
    actually parses RGW’s XML (Entries, categories, CapacityUsed) instead
    of returning empty {} fields.
  • docs — expands doc/radosgw/s3/serviceops.rst with usage-log
    requirement, date filters, and response field descriptions.

Why each part matters

Change Why
rgw_op.cc fix Core bug — without it, Entries is always empty on GET /?usage
QA signing fix Old helper signed /?usage in the URL path → 403 in real tests
sdk-extras shapes Raw XML from RGW didn’t match botocore’s expected structure
Documentation Operators need to know rgw enable usage log = true for ops stats

Testing

Tested locally with vstart (rgw enable usage log = true, usage tick 5s).

Smoke test (test_rgw_s3_getusage.py):

OK: RGW is up
CapacityUsed entries: 1
Entries users: 1
Total Ops in Entries: 11
PASS: GET /?usage returned capacity and usage log ops

Raw XML (awscurl) — Entries now has real ops (create_bucket,
put_obj, get_self_usage), plus Summary and CapacityUsed:

<Usage>
  <Entries>
    <User><Owner>testid</Owner>
      <Buckets>
        <Bucket><Bucket>getusage-test-bucket</Bucket>
          <categories>
            <Entry><Category>put_obj</Category><Ops>2</Ops>...</Entry>
          </categories>
        </Bucket>
      </Buckets>
    </User>
  </Entries>
  <Summary>...<TotalBytes>14</TotalBytes>...</Summary>
  <CapacityUsed>...<Bytes>14</Bytes>...</CapacityUsed>
</Usage>

boto3 (get_usage_stats.py with updated sdk-extras) — structured
Entries.User[].Buckets.Bucket[], Summary, and CapacityUsed all
populate correctly (HTTP 200).

Teuthology: usage-s3-getusage runs inside the radosgw-admin task when
the rgw:singleton suite is scheduled. Suggest:

jenkins test rgw:singleton

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

GET /?usage is a service-level request with no bucket in the URL,
so s->bucket is null and the usage log was never read. Entries and
per-category ops in the response were therefore always empty even
when usage logging was enabled. Read usage from the authenticated
user instead, matching RGWUsage::show() behavior.

Signed-off-by: ramin.najarbashi <[email protected]>
Extend radosgw-admin QA to call GET /?usage after usage data is
flushed and verify CapacityUsed, Entries, and non-zero Ops. This
guards the fix that reads usage from the authenticated user when no
bucket is present in the service-level request.

Signed-off-by: ramin.najarbashi <[email protected]>
s3_get_usage() used a broken SigV4 URL (?usage in path, empty region),
which returned 403 in teuthology. Sign GET / with usage query param and
default region us-east-1.

Extend usage-s3-getusage to verify Entries owner, Summary ops/bytes, and
cross-check against usage show. Add unit tests for XML parsing helpers.

RGW returns nested XML (Entries, categories, CapacityUsed) that botocore
could not parse into User/Bucket/Ops fields. Add wrapper shapes, flattened
lists, resultWrapper Usage, and GetUsageStatsRequest. Set region_name in
get_usage_stats.py example for correct SigV4 signing.

Document usage logging requirement, start-date/end-date parameters, and
Entries/CapacityUsed response fields alongside existing Summary stats.

Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche
RaminNietzsche requested review from a team as code owners June 14, 2026 11:56
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@cbodley
If possible, please check the PR. Most of the changes are related to the documentation and qa tests, the outputs of the tests are fixed in the description of the merge request

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@ceph/rgw Could someone please review this PR?

Core change: fix S3 GET /?usage to read the user usage log when no bucket
is in the URL (rgw_op.cc). Also includes QA, boto3 sdk-extras, and docs.

@cbodley — would appreciate your review on the RGW/S3 side when you have time.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@AliMasarweh Is it possible if you have a chance to check this PR and give your opinion?

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Gentle ping @AliMasarweh @cbodley @ceph/rgw — still looking for a review when you have a moment. Also need ok to test so Jenkins can run. Thanks!

@AliMasarweh

Copy link
Copy Markdown
Member

@RaminNietzsche thanks for your patience, I had tasks with close deadline and an urgent costumer issues that I am working on for the past month. so I couldn't review your change
I will ask if someone from RGW can review your change

@AliMasarweh AliMasarweh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the PR looks good, but I would like to keep the format of service-2.sdk-extras.json as it was before

@AliMasarweh

Copy link
Copy Markdown
Member

ok to test

Restore the previous formatting of service-2.sdk-extras.json and keep only
the GetUsageStats schema additions needed for the example client, per
review feedback.

Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche

Copy link
Copy Markdown
Member Author

would like to keep the format of service-2.sdk-extras.json as it was before

I restored the previous formatting of service-2.sdk-extras.json and kept only the GetUsageStats schema.

@AliMasarweh AliMasarweh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, a few nit picking comments about format
this will help identify where changes have occurred

},
"GetUsageStats":{
"name":"GetUsageStats",
"name": "GetUsageStats",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"name": "GetUsageStats",
"name":"GetUsageStats",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

Comment on lines +42 to +44
"method": "GET",
"requestUri": "/?usage",
"responseCode": 200

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"method": "GET",
"requestUri": "/?usage",
"responseCode": 200
"method":"GET",
"requestUri":"/?usage",
"responseCode":200

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

"shape": "GetUsageStatsOutput",
"resultWrapper": "Usage"
},
"documentationUrl": "https://docs.ceph.com/docs/master/radosgw/s3/serviceops#get-usage-stats",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"documentationUrl": "https://docs.ceph.com/docs/master/radosgw/s3/serviceops#get-usage-stats",
"documentationUrl":"https://docs.ceph.com/docs/master/radosgw/s3/serviceops#get-usage-stats",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

"documentation":"<p>A container for object tags filtering rules.</p>"
},
"GetUsageStatsOutput": {
"GetUsageStatsOutput":{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"GetUsageStatsOutput":{
"GetUsageStatsOutput": {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

Comment on lines +276 to +277
"Summary":{
"shape": "UsageStatsSummary",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"Summary":{
"shape": "UsageStatsSummary",
"Summary": {
"shape":"UsageStatsSummary",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

}
},
"UsageStatsSummary": {
"UsageStatsSummary":{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"UsageStatsSummary":{
"UsageStatsSummary": {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

Comment on lines +288 to +316
"members":{
"User":{
"shape": "UsageStatsSummaryUserList",
"locationName": "User"
},
"QuotaMaxBytes":{
"shape": "QuotaMaxBytes"
},
"QuotaMaxBuckets":{
"shape": "QuotaMaxBuckets"
},
"QuotaMaxObjCount":{
"shape": "QuotaMaxObjCount"
},
"QuotaMaxBytesPerBucket":{
"shape": "QuotaMaxBytesPerBucket"
},
"QuotaMaxObjCountPerBucket":{
"shape": "QuotaMaxObjCountPerBucket"
},
"TotalBytes":{
"shape": "TotalBytes"
},
"TotalBytesRounded":{
"shape": "TotalBytesRounded"
},
"TotalEntries":{
"shape": "TotalEntries"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"members":{
"User":{
"shape": "UsageStatsSummaryUserList",
"locationName": "User"
},
"QuotaMaxBytes":{
"shape": "QuotaMaxBytes"
},
"QuotaMaxBuckets":{
"shape": "QuotaMaxBuckets"
},
"QuotaMaxObjCount":{
"shape": "QuotaMaxObjCount"
},
"QuotaMaxBytesPerBucket":{
"shape": "QuotaMaxBytesPerBucket"
},
"QuotaMaxObjCountPerBucket":{
"shape": "QuotaMaxObjCountPerBucket"
},
"TotalBytes":{
"shape": "TotalBytes"
},
"TotalBytesRounded":{
"shape": "TotalBytesRounded"
},
"TotalEntries":{
"shape": "TotalEntries"
}
"members": {
"User":{
"shape": "UsageStatsSummaryUserList",
"locationName": "User"
},
"QuotaMaxBytes":{"shape": "QuotaMaxBytes"},
"QuotaMaxBuckets":{"shape": "QuotaMaxBuckets"},
"QuotaMaxObjCount":{"shape": "QuotaMaxObjCount"},
"QuotaMaxBytesPerBucket":{"shape": "QuotaMaxBytesPerBucket" },
"QuotaMaxObjCountPerBucket":{"shape": "QuotaMaxObjCountPerBucket"},
"TotalBytes":{"shape": "TotalBytes"},
"TotalBytesRounded":{"shape": "TotalBytesRounded"},
"TotalEntries":{"shape": "TotalEntries"}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied in f4fb1e0 — GetUsageStats entries now use the same compact key spacing as the surrounding operations/shapes.

Apply AliMasarweh's review nits so the GetUsageStats entries in
service-2.sdk-extras.json use the same compact key spacing as the
surrounding operations and shapes.

Signed-off-by: ramin.najarbashi <[email protected]>
Apply the same compact key spacing to the rest of the GetUsageStats /
UsageStats schema shapes introduced in this series, so they match the
surrounding entries and the earlier formatting nits.

Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche

Copy link
Copy Markdown
Member Author

@AliMasarweh thanks again for the review.

Formatting nits on service-2.sdk-extras.json are applied:

  • your inline suggestions → f4fb1e05b72
  • remaining GetUsageStats / UsageStats shapes from this series → 3ff9d3f8062

The related review threads are resolved. Jenkins is re-running on the latest tip.

If that looks good, a formal Approve would help move this forward. Happy to rebase onto current main once the new make check finishes, if you prefer.

Use the compact one-line member form AliMasarweh suggested for
UsageStatsSummary in service-2.sdk-extras.json.

Signed-off-by: ramin.najarbashi <[email protected]>
Collapse single-member shapes onto one line and align inner spacing
for all GetUsageStats/UsageStats* definitions added by this PR in
examples/rgw/boto3/service-2.sdk-extras.json, matching the compact
style requested in review.

Signed-off-by: ramin.najarbashi <[email protected]>

@AliMasarweh AliMasarweh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Great job @RaminNietzsche

@anrao19

anrao19 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

jenkins test api

@anrao19

anrao19 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-08-11-06:41.

@anrao19

anrao19 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-08-11-06:41.

pr testing completed and approved by @ivancich. @RaminNietzsche if no further testing is needed then this pr can be merged

@AliMasarweh
AliMasarweh merged commit 908eca6 into ceph:main Aug 17, 2026
7 checks passed
@RaminNietzsche

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants