A fresh site joins an existing federation¶
Status: Implemented.
Problem¶
A site that joins an existing federated Garage cluster with only node-local pools and Auto gateways never starts a Garage process, and nothing reports why in useful terms.
requireNodeLocalPoolActivationHeadroom decides whether one more
positive-capacity role fits under Garage's 256-role limit. It reads the
committed layout through the site's own garage Service. A site with no
Garage process yet has nothing behind that Service, so the read fails. For a
standalone cluster nodeLocalPoolBootstrapMayInferHeadroom then infers an
empty layout, but that exemption is disabled as soon as spec.remoteClusters
is set, because a joining site cannot assume the layout is empty. The
activation is refused, so the pool DaemonSet schedules nothing:
NodeLocalPoolsReady=False GarageRoleLimitExceeded: garage positive-capacity
role limit reached: cannot read the shared Garage layout before activating
<pool>/<node>: reading committed Garage layout for node-local-pool recovery:
... GetClusterLayout ... connection refused
Gateways do not break the cycle: Auto-mode gateway additions wait until layout
convergence can be verified, which again needs a local process
(garagecluster_automode_gateway.go: "Gateway identities are never the
empty-cluster bootstrap"). The site stays Pending forever. It was found by
re-adding a rebuilt site (empty disks, new identities) to a federation whose
layout was at version 218.
Unblocking the first process exposes a second defect. A federated site whose
local Garage is still at layout version 0 can commit a layout of its own: the
federation import stages the remote roles on the empty local layout and
applies it, and so does a GarageNode applying its own role. Garage merges
layout histories by version number
(src/rpc/layout/history.rs, LayoutHistory::merge): a remote history whose
min_stored is above the local current version replaces it wholesale, but two
different layouts with the same version are never reconciled:
ERROR garage_rpc::layout::history: Inconsistent layout histories: different
layout compositions for version 1. Your cluster will be broken as long as this
layout version is not replaced.
Against a federation at version 218 the stray local version 1 is discarded. Against a federation still at version 1, both sites hold different version-1 layouts until a later version replaces them. The new e2e scenario reproduces exactly that: with only the activation fix, both sites logged that error 18 times before version 2 superseded the conflicting version 1.
Decision¶
First activation reads the shared layout from a remote site¶
requireNodeLocalPoolActivationHeadroom keeps its local read. When that read
fails and the standalone inference does not apply, the new
federatedNodeLocalPoolBootstrapLayout covers the federated counterpart of the
standalone bootstrap state: storage.replicas: 0, no connectTo, no
GarageNode for the cluster yet, and spec.remoteClusters set. It reads
GetClusterLayout from every configured remote concurrently, with each
remote's own admin token and a 10-second timeout per remote, and the unchanged
headroom computation runs on the highest-version layout returned. The self
entry (zone equal to the local zone) and entries without an Admin API endpoint
are skipped.
Sites of one federated cluster converge on the same committed layout, but a
remote that is itself still joining serves version 0. Taking the first remote
that answers would let such a peer hide the committed layout of another, so the
highest version wins; remotes that fail are ignored while another answers. If no remote
answers, activation stays refused and the condition message carries both the
local and the remote errors. Once any GarageNode exists, the local Admin API is
the source of truth again and an outage there keeps failing closed exactly as
before. The other callers of getNodeLocalPoolCommittedLayout (cleanup,
out-of-service, retirement cancel, identity recovery) are unchanged.
A version-0 site never commits a layout while a remote has one¶
federatedJoinMustAwaitSharedLayout(local, remote) is true only when the local
layout is at version 0 and a remote layout is known to be above version 0. The
remote layout compared is the highest version any configured remote serves.
Two writers check it before committing:
- the federation import (
addRemoteNodesToLayoutLocked), using its fresh read of the remote it imports from together with every other remote's layout: it logs and returns without staging, so a site never commits version 1 by importing another joining site's roles while a third site is committed; the connections it has just made let Garage gossip the committed layout to the site; - the GarageNode role commit (
reconcileNode), throughawaitFederatedSharedLayout, which reads a remote layout only when the local layout is at version 0 andspec.remoteClustersis set, and returnserrLayoutMutationPendingwith the remote name and version.
Once Garage has delivered the committed layout, the local version equals the remote's and both writers proceed on top of it, so the new site's roles arrive as the next version of the one shared history.
Only positive evidence blocks. An unreachable remote, or every site at version
0, leaves behavior as it is today: the first site of a federation still
bootstraps while its peers do not exist yet, and sites that bootstrap together
keep the existing shared-bootstrap path (including the staged-peer-role
exception in garageNodeStagingIntent).
Compatibility and data safety¶
No API, CRD, status, or generated-file change. The remote admin-token
resolution moved into a package-level function shared by both controllers;
getRemoteAdminToken delegates to it unchanged.
The activation change only adds a way to decide headroom where the operator previously refused forever; the decision itself and Garage's hard maximum are unchanged. The version-0 guard only withholds a layout commit that would have created a conflicting layout version, and only while a remote positively reports a committed layout. Sites with a committed local layout never perform the extra remote read.
Rollback to an operator without this change restores the previous behavior: a
fresh node-local-pool site joining a federation is again stuck in Pending.
Nothing is persisted by the change.
Alternatives considered¶
- Boot the new site standalone, then add
remoteClusters. Creates a second independent layout that must later be merged, which is the inconsistency this design avoids. Documented as unsafe in the operator notes for this case. - Infer an empty layout for federated bootstraps as well. Wrong for a site joining an established layout; the headroom check would be meaningless.
- Route every
getNodeLocalPoolCommittedLayoutcaller through the remote read. Some callers feed cleanup and retirement decisions that fail closed today when the local Admin API is down; changing their failure behavior is out of scope. - Let Garage's merge resolve the version-1 conflict. It does once a later version replaces both, but every process logs a broken-cluster error in the meantime, and the window is not bounded by the operator.
Test plan¶
- Unit (
node_local_pool_federated_bootstrap_test.go): the first activation uses a remote layout served by anhttptestAdmin API (headroom admitted, hard maximum and staged additions enforced from the remote layout, remote token sent); it fails closed when the remote is unreachable, the token is missing, or only a self entry exists; it never reads a remote once a GarageNode exists, with default-group replicas, or withconnectTo. - Unit (
federated_shared_layout_test.go): the version-0 guard truth table andawaitFederatedSharedLayoutagainst anhttptestremote, including the unreachable-remote and shared-bootstrap cases. - envtest (
federation_test.go): the federation import performs no layout write at local version 0 while the remote is committed, and still stages and applies when every site is at version 0. - e2e (
hack/e2e-multicluster.sh,test_node_local_pool_site_joins_federation): site A commits its own layout; site B is created with only a node-local pool andremoteClustersfrom the start. The pool member must start, site A's committed layout must gain a zone-b storage role, both sites must see every storage node, and both must report the same layout version with no "Inconsistent layout histories" in any Garage log.
Documentation¶
The node-local pools guide gains a short section on adding a fresh site to an existing federation.