Skip to content

rgw: redirect to the endpoint of the bucket's zonegroup - #70931

Merged
anrao19 merged 2 commits into
ceph:mainfrom
RaminNietzsche:wip-rgw-64983-zonegroup-redirect
Sep 3, 2026
Merged

anrao19 merged 2 commits into
ceph:mainfrom
RaminNietzsche:wip-rgw-64983-zonegroup-redirect

Conversation

@RaminNietzsche

Copy link
Copy Markdown
Member

Problem

When a request for a bucket that lives in another zonegroup reaches a gateway,
rgw_build_bucket_policies() correctly returns ERR_PERMANENT_REDIRECT, but
s->zonegroup_endpoint was read from the local zonegroup:

s->zonegroup_endpoint = rgw::get_zonegroup_endpoint(zonegroup);  // local zonegroup
s->zonegroup_name = zonegroup.get_name();

if (!zonegroup.equals(s->bucket->get_info().zonegroup)) {
  ...
  return -ERR_PERMANENT_REDIRECT;

abort_early() then builds the Location header from that endpoint, so the
301 points at the gateway the client just used. Clients that follow redirects
resend the same request in a tight loop.

Example from a two-zonegroup cluster:

s3:stat_bucket NOTICE: request for data in a different zonegroup
    (70271812-eb5c-472a-9050-16e289e78941 != 74506436-cfb6-4105-8a8c-edd0c62632b7)
s3:stat_bucket init_permissions on :xxx[...] failed, ret=-2024

...with a Location header naming the local zonegroup's first endpoint.

This is the loop reported in http://tracker.ceph.com/issues/64983, where
two-zonegroup teuthology jobs spent hours redirecting to the same endpoint
until the requests failed with RequestTimeTooSkewed.

Fix

Add rgw::find_zonegroup_by_id(), which resolves a zonegroup id against the
local zonegroup or the current period, and use it to take the endpoint and name
from the zonegroup that actually holds the bucket.

When the bucket's zonegroup is not part of the period, the endpoint is left
empty and the reason is logged, so the response carries no Location rather
than pointing the client back at itself.

Single-zonegroup deployments are unaffected: the lookup returns the local
zonegroup, exactly as before.

This also restores Request.ZoneGroup.Name and Request.ZoneGroup.Endpoint in
lua scripts to the bucket's zonegroup, which is what they reported before
e2eb66a dropped the per-bucket zonegroup lookup.

Testing

Built and ran locally (gcc 12, Release):

$ ninja unittest_rgw_zone
[189/189] Linking CXX executable bin/unittest_rgw_zone

$ ./bin/unittest_rgw_zone
[==========] Running 9 tests from 2 test suites.
...
[  PASSED  ] 9 tests.

The cross-zonegroup redirect path itself is exercised by the rgw/multisite
suite with realms/two-zonegroup.yaml; I have not run teuthology for this
change.

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.

rgw_build_bucket_policies() returns ERR_PERMANENT_REDIRECT when a request
reaches a zonegroup that does not hold the bucket, but s->zonegroup_endpoint
was read from the local zonegroup. abort_early() builds the Location header
from that endpoint, so the client was redirected back to the gateway it had
just used. Clients that follow redirects then retry in a tight loop.

Look the bucket's zonegroup up in the current period and take the endpoint
from there instead. If that zonegroup is not part of the period, leave the
endpoint empty and log the reason rather than pointing the client at itself.

This also restores Request.ZoneGroup.Name and Request.ZoneGroup.Endpoint in
lua scripts to the bucket's zonegroup, which is what they reported before
the endpoint lookup was dropped.

Fixes: http://tracker.ceph.com/issues/64983
Fixes: e2eb66a
Signed-off-by: ramin.najarbashi <[email protected]>
Add unittest_rgw_zone for rgw::get_zonegroup_endpoint() and the new
rgw::find_zonegroup_by_id(), including the case that caused the redirect
loop: a bucket in another zonegroup must resolve to that zonegroup's
endpoint and not the local one.

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

Copy link
Copy Markdown
Member Author

@cbodley @adamemerson @yuvalif

Could you take a look when you have time?

We hit this redirect loop issue after a recent update and are currently affected by it. This PR aims to fix the problem described in tracker #64983.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@cbodley @adamemerson @yuvalif — follow-up to help unblock this.

Tracker: http://tracker.ceph.com/issues/64983 (the earlier #64983 auto-link pointed at a different GitHub PR). I added a note there linking this PR. The issue still has Pull request ID 56874, which was only the QA/multisite stabilization change and does not fix the bad Location endpoint; I could not update that custom field with my Redmine role — please point it at 70931 if you can.

Why this is urgent for us: after a recent upgrade we hit the redirect loop in a multi-zonegroup deployment (client follows 301 back to the same local endpoint). Same failure mode as the two-zonegroup teuthology hang described on the tracker.

Ask: when you have a moment, ok to test so Jenkins can run, and a review of the lookup/Location change would be much appreciated. Local unittest_rgw_zone is 9/9 green on the PR.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Hi @cbodley @adamemerson @yuvalif — gentle bump when you have a spare moment.

No rush on my side; just checking whether an ok to test and a quick look at the zonegroup redirect change would be possible. Happy to adjust anything that looks off.

Thanks again.

@adamemerson

Copy link
Copy Markdown
Contributor

ok to test

@anrao19

anrao19 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-08-19-07:20.

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@adamemerson — a question on make check (arm64), when you have a moment.

x86_64 make check (and API / windows) are green. The arm64 job still shows failed: https://jenkins.ceph.com/job/ceph-pull-requests-arm64/102096/

That console URL currently returns 404 (log not available), so I cannot tell whether it is this change or an infra/runner issue.

Is there anything I should do on this PR (rebase, code fix), or is a retrigger of jenkins test make check arm64 enough from your side?

Thank you.

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@anrao19

anrao19 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-08-19-07:20.

pr testing completed and approved by @ivancich , more details in : https://tracker.ceph.com/issues/79605
@RaminNietzsche , if no further testing is needed then this pr can be merged

@anrao19
anrao19 merged commit ea93efc into ceph:main Sep 3, 2026
8 checks passed
@RaminNietzsche
RaminNietzsche deleted the wip-rgw-64983-zonegroup-redirect branch September 3, 2026 14:12
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.

3 participants