Skip to content

feat(placement): reconcile RGW across the cluster - #889

Open
johnramsden wants to merge 1 commit into
rgw-stack/08-policy-objectfrom
rgw-stack/09-reconcile
Open

johnramsden wants to merge 1 commit into
rgw-stack/08-policy-objectfrom
rgw-stack/09-reconcile

Conversation

@johnramsden

@johnramsden johnramsden commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Description

This is where the feature turns on end to end, from PUT /1.0/placement through to a member dispatch. reconcilePlacement now calls the new applyRgwPlacement once the control services (mon, mgr, mds) are settled, so control quorum is established before any gateway moves.

applyRgwPlacement splits the policy's members into those with rgw.enabled=true and those with enabled=false, sorted for a deterministic dispatch order, and calls enableRgwServiceFunc for every enable, collecting failures instead of stopping at the first. If any enable failed it returns without disabling anything, so a migration never stops the old gateway before the new one serves. Only when every enable succeeds does it move to the disable loop, which runs unconditionally: RGW has no keep-one rule, so a pure scale-to-zero is allowed, unlike mon/mgr/mds.

Error classes cross the network boundary here: rgwDispatchFailure treats a forwarded HTTP 400 from the member's own serviceErrorResponse as client-classified, and everything else — an unreachable member, a failed start, a failed teardown — as operational. rgwAggregateError then returns ErrRgwFrontendInvalid only when every collected failure was a forwarded 400, and ErrPlacementOperationFailed the instant any failure was not, so a genuinely mixed batch answers 500, never 400. retainRefusals appends an earlier keep-one refusal from the control pass to a later failure, so the reported reason names both instead of one silently replacing the other.

prod_wiring.go wires the production hooks, each a fail-closed default: with no implementation assigned, the outer function returns an explicit error naming the member rather than silently reporting success. prodEnableRgwServiceFunc first calls client.CheckRGWPlacementSupport, which asks the target member's own GET /1.0/cluster/capabilities for placement-rgw and fails closed with 400 if it is missing — an older member would otherwise ignore ssl and could turn a TLS retry into plaintext. api/capabilities.go advertises placement-rgw from this commit on, since this is the commit that starts acting on the field.

Stack: PR 9 of 13. Merge in order. Each PR is one logical change on top of the one before it.

  1. feat(db): add a table for each member's last applied RGW frontend #881 feat(db): add a table for each member's last applied RGW frontend
  2. fix(services): keep error classes through the service enable path #882 fix(services): keep error classes through the service enable path
  3. feat(api): describe an RGW placement as an object with explicit TLS intent #883 feat(api): describe an RGW placement as an object with explicit TLS intent
  4. feat(rgw): make the member-side RGW apply safe to repeat #884 feat(rgw): make the member-side RGW apply safe to repeat
  5. feat(rgw): wait until the gateway really serves the requested frontend #885 feat(rgw): wait until the gateway really serves the requested frontend
  6. feat(rgw): reuse the member's own pair when TLS is asked for without one #886 feat(rgw): reuse the member's own pair when TLS is asked for without one
  7. fix(rgw): make RGW disable converge when repeated or interrupted #887 fix(rgw): make RGW disable converge when repeated or interrupted
  8. feat(placement): accept the RGW object in the policy and keep its secrets out #888 feat(placement): accept the RGW object in the policy and keep its secrets out
  9. feat(placement): reconcile RGW across the cluster #889 feat(placement): reconcile RGW across the cluster (this PR)
  10. test(robot): add the single-VM RGW placement suite #890 test(robot): add the single-VM RGW placement suite
  11. test(robot): add the three-VM RGW placement suite #891 test(robot): add the three-VM RGW placement suite
  12. docs: keep the RGW placement contract in HACKING.md for now #892 docs: keep the RGW placement contract in HACKING.md for now
  13. fix(rgw): do not trust a pending-apply marker the operator completed by hand #893 fix(rgw): do not trust a pending-apply marker the operator completed by hand

Reviewer note: two later PRs in this stack only add proof and documentation on top of this, nothing functional — the single-VM and three-VM Robot suites exercise this reconciler against a real snap and a real gateway, and the HACKING.md write-up lands after the behaviour it documents already exists.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • Unit tests pass at this stack's cumulative tip

Contributor checklist

Please check that you have:

  • self-reviewed the code in this PR
  • added code comments, particularly in less straightforward areas
  • checked and added or updated relevant documentation
  • checked and added or updated relevant release notes
  • added tests to verify effectiveness of this change

@johnramsden
johnramsden added this pull request to stack #894 September 23, 2026 04:20
@johnramsden johnramsden changed the title rgw stack/09 reconcile feat(placement): reconcile RGW across the cluster Sep 23, 2026
@johnramsden
johnramsden marked this pull request as ready for review September 23, 2026 04:30
@johnramsden
johnramsden marked this pull request as draft September 23, 2026 06:23
@johnramsden
johnramsden marked this pull request as ready for review September 23, 2026 06:25
@johnramsden
johnramsden force-pushed the rgw-stack/09-reconcile branch 2 times, most recently from 2397974 to df46e92 Compare September 24, 2026 19:32
@johnramsden
johnramsden force-pushed the rgw-stack/09-reconcile branch from df46e92 to 59dd35e Compare September 29, 2026 18:43
@johnramsden
johnramsden force-pushed the rgw-stack/09-reconcile branch from 59dd35e to 02c8c88 Compare September 29, 2026 19:50

@sabaini sabaini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@johnramsden
johnramsden force-pushed the rgw-stack/09-reconcile branch from 02c8c88 to 57e3744 Compare October 1, 2026 22:24
This is where the feature turns on end to end, from PUT /1.0/placement through to a member dispatch. reconcilePlacement now calls the new applyRgwPlacement once the control services (mon, mgr, mds) are settled, so control quorum is established before any gateway moves.

applyRgwPlacement splits the policy's members into those with rgw.enabled=true and those with enabled=false, sorted for a deterministic dispatch order, and calls enableRgwServiceFunc for every enable, collecting failures instead of stopping at the first. If any enable failed it returns without disabling anything, naming the disables it held back, so a migration never stops the old gateway before the new one serves -- the commit message's own words for the invariant. Only when every enable succeeds does it move to the disable loop, which runs unconditionally and collects failures the same way: RGW has no keep-one rule, so a pure scale-to-zero is allowed, unlike mon/mgr/mds.

Error classes cross the network boundary here: rgwDispatchFailure treats a forwarded HTTP 400 from the member's own serviceErrorResponse (added inert in "fix(services): keep error classes through the service enable path") as client-classified, and everything else, an unreachable member, a failed start, a failed teardown, as operational. rgwAggregateError then returns ErrRgwFrontendInvalid only when every collected failure was a forwarded 400, and ErrPlacementOperationFailed the instant any failure was not, so a genuinely mixed batch answers 500, never 400. retainRefusals appends an earlier keep-one refusal from the control pass to a later failure, including a failed control removal, so the reported reason names both instead of one silently replacing the other. cmdPlacementPut checks ErrPlacementOperationFailed first, ahead of the existing client-error ladder, so that combination still answers 500.

cmd/microcephd/prod_wiring.go wires the two hooks, each a fail-closed default: with no production implementation assigned, the outer function returns an explicit error naming the member rather than silently reporting success, so a daemon binary that forgets to wire one cannot hide the gap. prodEnableRgwServiceFunc first calls the new client.CheckRGWPlacementSupport, which asks the target member's own GET /1.0/cluster/capabilities for "placement-rgw" and fails closed with 400 if it is missing -- an older member would otherwise ignore ssl and could turn a TLS retry into plaintext. That capabilities endpoint becomes ProxyTarget so it can be asked of another member, not only whichever one answered this request. prodRemoveRgwServiceFunc runs no such check: a removal carries no TLS intent, so there is nothing an older member could silently downgrade. api/capabilities.go advertises "placement-rgw" from this commit on, since this is the commit that starts acting on the field, not the one that defined it.

Two later branches only add proof and documentation on top of this, nothing functional: the single-VM and three-VM Robot suites in "test(robot): add the single-VM RGW placement suite" and "test(robot): add the three-VM RGW placement suite" exercise this reconciler against a real snap and a real gateway, and the HACKING.md write-up lands after the behaviour it documents already exists.

Co-authored-by: Peter Sabaini <peter.sabaini@canonical.com>
Assisted-by: claude-code:claude-fable-5-1
Assisted-by: pi:gpt-6-astra
Signed-off-by: John Ramsden <john.ramsden@canonical.com>
@johnramsden
johnramsden force-pushed the rgw-stack/09-reconcile branch from 57e3744 to 24e2bdf Compare October 6, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants