Repository navigation
fix(rest): answer a resize only after every replica has grown - #281
Conversation
Nothing told the cluster when a grow had reached the DRBD device: the satellite resized DRBD only on the pass that grew its backing volume, and wrote nothing about it. A drbdadm resize that failed after the backing grew was never run again, and a backing volume that was already large enough (LINSTOR sizes it with the metadata on top) never got one at all. Each replica now records in its status the definition size it has applied through every layer, written only after a pass in which storage, LUKS and drbdadm resize all succeeded. While that lags the definition, the next pass resizes DRBD again. A replica that never reported one, such as every replica right after an upgrade, is not resized for nothing. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi's ControllerExpandVolume returns as soon as the volume definition PUT does, and kubelet runs resize2fs right after. blockstor answered the PUT once the new size was stored, so on a busy node the filesystem resize ran against a DRBD device that still had the old size, and nothing ran it again. LINSTOR answers only after its satellites have grown the backing volume and then DRBD. The PUT now waits until every diskful replica on a connected node reports the new size applied, and names a disconnected one in a WARN_NOT_CONNECTED entry instead of waiting for it, as LINSTOR does. When the wait outlasts the external resizer's timeout, linstor-csi's retry reads the definition, finds the requested size, skips the PUT and reports success. So while a grow is in progress, the volume definition reads report the size the replicas have applied, the retry PUTs again, and that PUT waits as well. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The satellite logged "repaired the activity log left by an unclean shutdown" whenever its metadata probe found a log to apply. DRBD clears the activity log's clean flag on every detach, a graceful drbdsetup down included, so the line also followed every clean down and up, and read as evidence of a crash that never happened. The repair itself is right; only the message changes. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The blockstor CLI reached a cluster only through the ambient kubeconfig, so on a workstation with several clusters configured an operator had to remember to switch the current context before every command, including the encryption ones. It now takes kubectl's two flags; with either, it reads only that file or context and does not fall back to the in-cluster service account. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
While a grow is in progress the volume definition reads report the size the replicas have applied rather than the new one, which is a deliberate difference from LINSTOR; record it with the rest. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
A resize waits for every connected diskful replica to report the new size. When a replica's pass keeps failing (a missing LUKS key, an unknown pool, a refused lvextend) nothing told the waiting request, so `vd set-size` hung until the client gave up and reads showed the old size, where LINSTOR answers with its satellite's error. The satellite now keeps the error of its last failed pass on the Resource status, with the volume sizes that pass was applying, and drops it once a pass succeeds. The sizes let a waiting resize tell a failure of this grow from one left by an earlier pass. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The request context is the server's base context, so a controller that stopped while a grow waited (a rollout, a leader change) ended the wait with the connection still open, and net/http sent 200 with no body. golinstor does not decode the body of a PUT, so linstor-csi took that for a finished expansion and kubelet grew the filesystem on a device still at the old size. A cancelled wait now answers 503 with an error entry; a caller that is really gone just drops it. A replica whose satellite failed its pass at the new size now ends the wait with that satellite's error, as LINSTOR answers, instead of holding the request until the client times out. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The grow wait skipped a replica only when its node was explicitly OFFLINE, and treated a node it could not read as online. A replica on an evicted node, or on one in any other state the heartbeat reports, was waited for until the client gave up. Only an ONLINE, not evicted or lost node is now waited for; every other replica is reported in a WARN_NOT_CONNECTED entry, as LINSTOR does for a satellite it cannot reach. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A grow extended the backing to the definition size and reported the definition size as applied after any pass that returned without an error. With DRBD's internal metadata at the end of that backing, the device ended short of the definition, and short of what LINSTOR gives the same volume. An adopted LINSTOR volume, whose backing already carries the metadata, was not extended at all when the new size fit in it, so drbdadm resize had nothing to grow, yet the size was reported applied and the resize answered. resize2fs then grew nothing. The backing now grows to the size plus DRBD's internal metadata and the LUKS header, as LINSTOR's size calculators do, with the bitmap sized for 15 peer slots, which also covers LINSTOR's default seven. A pass with a grow pending reports the size applied only once the device the consumer sees, read from sysfs, shows it, and the pass is repeated until then. A device held back by a peer whose backing has not grown does not grow from a local resize, and every pass that resizes keeps the late-add self-heals off. The retried resize therefore stops after three passes that succeeded without growing the device. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR's client sees a dropped connection when the controller stops during `vd set-size`; blockstor answers the request with 503 and an error entry instead, because an empty 200 reads as a finished grow. Record the difference with the rest. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
The LINSTOR side checks out: at v1.33.1, CtrlVlmDfnModifyApiCallHandler.updateSatellitesInScope chains the backing resize, then resizeDrbd, then finishResize, and VolumeDefinitions.java returns the PUT through mapToMonoResponse. linstor-csi's ControllerExpand skips the PUT when the GET already shows the requested size, which is the retry gap the applied-size read closes. Blocking on the wait in the inline comment.
CLAUDE.md asks for cli-matrix/vd-resize-full-lifecycle.sh and replay/vd-resize-full-lifecycle.yaml to pass on the stand for a change to vd s and DRBD resize, and the description says this has not been run. CI does not run the cli-matrix cells, so the green e2e lanes do not cover this.
| continue | ||
| } | ||
|
|
||
| if !isSatelliteConnected(ctx, s.Store.Nodes(), rsc.NodeName) { |
There was a problem hiding this comment.
This skips a replica on an offline node, but the replicas that stay online cannot finish either. While a diskful peer that holds a bitmap slot is unreachable, DRBD 9 caps a resize at the last agreed size: in drbd_new_dev_size (drbd_nl.c), the not-all-connected branch takes min_not_zero(p_size, la_size) unless --assume-peer-has-space is passed, and Adm.Resize does not pass it. So with one diskful node down, or with the DRBD link cut while both satellites stay ONLINE, every awaited replica keeps its old applied size. The PUT then does not return until the peer is back, and reportAppliedSizes keeps vd l at the old size for that whole time.
tests/e2e/cli-matrix/vd-resize-peer-disconnected-defers.sh pins the opposite: vd s returns while N2 is partitioned, and vd l reaches 2 GiB within 60s. The unit tests here fake the satellite status, so they cannot see this. Please don't await a replica whose DRBD connection to a diskful peer is down (it can go into the WARN_NOT_CONNECTED entries), or change that contract on purpose and update the cell.
There was a problem hiding this comment.
You're right, and it is worse than the offline case: with the link cut and both satellites ONLINE, every awaited replica stays at the old size, so the PUT hung for the whole partition. 105725a stops waiting for a diskful replica whose satellite reports its DRBD connection to another diskful, active replica as down. It is left out of the applied size vd l reports and is named in a WARN_NOT_CONNECTED entry with the peers it is cut off from, as for an offline node. That keeps the contract cli-matrix/vd-resize-peer-disconnected-defers.sh pins. A down connection to a diskless peer still counts as nothing, since it does not cap the grow. da1514b matches the peer by node key, since DRBD reports the peer under the spelling the node was created with. TestVDGrowSkipsReplicaCutOffFromDiskfulPeer covers both and hangs without either fix. Row 96 in the known deltas now says the same.
While a diskful peer is not connected, DRBD 9 caps a grow at the last agreed size, and neither blockstor nor LINSTOR passes --assume-peer-has-space. A replica on an online node but cut off from such a peer therefore never reports the new size until the link is back, and the resize waited for it: the PUT hung for the whole partition and vd l stayed at the old size, against the vd-resize-peer-disconnected-defers contract. LINSTOR answers that resize, so the wait skips such a replica and names it in a WARN_NOT_CONNECTED entry, as it does for an offline satellite. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The satellite keys a DRBD connection by the peer name DRBD reports, which keeps the spelling the node was created with. Comparing it with the node's name byte for byte missed a cut-off peer spelled in another case, so the resize waited on that replica for the whole partition. The naming guard also flags the raw comparison. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Keep main's longer retry for an apply whose only failures are metadata refusals, but never past applyFailureRequeue while a grow still waits for its device. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Main's repairUncleanMetadata takes the desired resource, not its name; the test this branch adds still called it the old way. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
The CLAUDE.md rule that asks for the cli-matrix and L7 artefacts per change is being reworked in #317. Stand coverage for this branch comes from the dev pre-releases instead: it has been in v0.4.0-alpha.2 through v0.4.0-alpha.17, which run on a real cluster, and 105725a and da1514b go into the next one. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
The hang is fixed. A replica whose satellite reports its connection to a diskful, active peer as down is no longer awaited. It is left out of the applied size and named in a WARN_NOT_CONNECTED entry, and peers are matched by node key. The observer keeps a down connection in the map until its destroy frame, so the check sees a partition and not only a removed peer. TestVDGrowSkipsReplicaCutOffFromDiskfulPeer and row 96 cover it. The merge resolution in runApply keeps both requeue paths, so a refusal cannot hold back a pending grow.
The red unit job is TestReconcileComesBackWhenAPlacementHoldRunsOut and TestManagerIndexesCachedReplicasByDefinitionKey, which fail the same way on main at bd9d4df.
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
LGTM. Same patch as my approval at b4f32cf, merged with current main for a fresh CI run before merging.
Main now carries #281, which moved the grow step into grow.go and tracks the size each replica applied. The lower disk sizing of this branch moves there: a grow sizes the backing for the largest device any replica reports, and the grow that stays inside a lower disk sized for metadata is planned by planGrow. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
What this fixes
Online expansion of a mounted replicated PVC could finish with the filesystem still at the old size. blockstor answered linstor-csi's
PUT /v1/resource-definitions/{rd}/volume-definitions/{vn}as soon as the new size was stored. linstor-csi'sControllerExpandVolumereturns when that PUT returns and does no polling of its own, so the external resizer reportedFileSystemResizeRequiredand kubelet ranNodeExpandVolume(resize2fs) at once. On a test cluster with busy satellites the zvol had grown on two of three nodes and/sys/block/drbdN/sizewas still the old size at that moment. resize2fs grew nothing, kubelet recorded the expansion as done, and the filesystem only reached the new size when the pod was restarted and the resize ran at mount.LINSTOR answers the same PUT only after its satellites have grown the backing volume and then DRBD.
CtrlVlmDfnModifyApiCallHandler.updateSatellitesInScopechains the backing resize on every satellite, then the DRBD resize on one diskful volume, then the cleanup, and the REST layer collects that whole flux before it writes a response (ApiCallRcRestUtils.mapToMonoResponse). This PR gives blockstor the same contract.Changes
Satellite. Each replica now records
status.volumes[].appliedSizeKib: the volume definition size it finished applying. A pass with no grow pending writes the definition size. A pass with a grow pending writes it only when storage, LUKS anddrbdadm resizeall succeeded and the device the consumer sees (the DRBD device, or the LUKS mapper or backing device without DRBD) reads at least that size in sysfs; until then the previous value stays and the satellite repeats the pass every few seconds. blockstor runsdrbdadm resizeon every diskful replica after its own backing grows, and DRBD 9 commits a resize as a two-phase commit across the connected peers, using each peer's current backing size. So the last replica to grow its backing resizes the device everywhere, and once every diskful replica reports the new size, the device has the new size on every node where it is attached. While a replica's applied size lags the definition, its next pass runsdrbdadm resizeagain. Before, the resize ran only on the pass that grew the backing volume: adrbdadm resizethat failed afterwards was never retried, and a backing volume that was already large enough (LINSTOR sizes it with the DRBD metadata on top) never got one. A replica that has not reported an applied size, which is every replica right after an upgrade, is not resized for nothing. A resize that succeeds and still leaves the device short, which is a device held back by a peer whose backing has not grown yet, is retried on at most three passes, because every pass that resizes keeps the late-add self-heals off; the peer's own resize then grows the device and the next pass reports it.Backing size. A grow now extends the backing to the definition size plus DRBD's internal metadata (superblock, default activity log, and a bitmap sized for 15 peer slots, which also covers LINSTOR's default seven) plus the LUKS2 header when LUKS is in the stack, rounded up to whole MiB, the way LINSTOR's layer size calculators size it. Before, the backing grew to the definition size, so the DRBD device ended short of the definition by its metadata, and an adopted LINSTOR volume whose backing already carried the metadata was not extended at all when the new size fit inside the old backing.
drbdadm resizethen had nothing to grow, the size was reported applied, and resize2fs grew nothing. With external metadata the data volume grows to the definition size as before.Apply errors. A satellite pass that fails now leaves its error on the Resource as
status.applyFailure, with the volume sizes the pass was applying, and a pass that succeeds removes it. Only a change is written, so a steady replica costs no extra API call.REST. A grow PUT now waits until every diskful, active replica on a node the heartbeat reports
ONLINEreports the new size applied. A replica on any other node (offline, evicted or lost, in another connection state, or one that cannot be read) is not waited for and is named in aWARN_NOT_CONNECTEDentry, the way LINSTOR's controller reports a satellite it could not reach; it catches up when it reconnects. A diskful replica on anONLINEnode whose DRBD connection to another diskful, active replica is down is not waited for either: DRBD 9 caps a grow at the last agreed size while such a peer is not connected (drbd_new_dev_sizewithout--assume-peer-has-space, which LINSTOR does not pass either), so its device cannot grow before the peer is back. It gets aWARN_NOT_CONNECTEDentry naming the peers, and the reads during the grow leave it out of the applied size, sovd set-sizereturns andvd lshows the new size during a partition, ascli-matrix/vd-resize-peer-disconnected-defers.shexpects. The wait has no deadline of its own, as in LINSTOR. It ends in one of three ways: the replicas have grown (200); an awaited replica reports that its pass at this size failed (500 with that satellite's error, as LINSTOR returns it; a failure left from a pass at an older size does not count); or the request is cancelled (503 with an error entry). The last case matters because the request context is the server's: when the controller stops during a grow (a rollout or a leader change), the handler returns with the connection still open, and an empty 200 would reach golinstor, which does not decode the body of a PUT, so linstor-csi would report the expansion done. A caller that has really gone away just drops the 503. That answer is recorded as row 97 indocs/cli-parity-known-deltas.md, since LINSTOR drops the connection instead.The blocking PUT alone would not have fixed the incident. The external resizer there runs with a one minute timeout and the grow took about three. When the PUT outlasts the timeout, linstor-csi retries, reads the volume definition, finds the requested size, skips the PUT and reports success, and kubelet runs resize2fs on the old device again. LINSTOR has the same gap but rarely hits it because its resize takes seconds. So while a grow is in progress, the volume definition reads (
GET .../volume-definitions/{vn}, the per definition list, the cluster-wide view and the definition list withwith_volume_definitions, whichlinstor vd lreads) report the smallest size the awaited replicas have applied. The retry then sends the PUT again, and a PUT of the size already stored waits too. This is a deliberate difference from LINSTOR, which shows the new size with aRESIZEflag; it is recorded as row 96 indocs/cli-parity-known-deltas.md. In steady state every replica has applied the definition size and the reads are unchanged.Minor items from the same adoption:
drbdsetup downand brought up again. The probe does not misread anything: DRBD clears the activity log's clean flag on every detach, a graceful one included (drbd_state.c: "always require a drbdmeta apply-al run"), anddrbdadm attachapplies it before attaching; the probe just meets the log first. The repair is correct, so only the message changes, and it no longer reads as a crash.blockstorCLI takes--kubeconfigand--context, as kubectl does. With either it reads only that file or context and does not fall back to the in-cluster service account; without them it behaves as before.MetadataCreatedwith reasonCreateMdSucceededon adopted replicas is fixed in fix(satellite): reconcile a new resource within seconds on a busy node #277, which adds a separate reason for metadata found on the volume.rs-discard-granularitygained by adopted LINSTOR clones is handled in fix(satellite): render volume definition disk options the way LINSTOR does #275: a volume whose definition carries no discard options from LINSTOR no longer gets one derived from the device.metadata.finalizersneeds an unstructured apply object (a typed one claims the empty required spec fields) and an envtest to prove it merges, since the fake client treats the list as atomic. That is better done together with the per-node finalizer question in the deletion work of fix(storage)!: delete storage only on request, the way LINSTOR does #271.Behaviour notes
vd set-sizeand linstor-csi's expansion now take as long as the slowest online diskful replica takes to grow, as they do with LINSTOR. A satellite whose pass fails at the new size ends the PUT with its error.status.volumes[].appliedSizeKibandstatus.applyFailure. Nothing else writes them, and the REST wire shape is unchanged apart from the size reported during a grow and the 500 and 503 answers above.Interactions with other open PRs
ObservedGIinDesiredVolume(pkg/satellite/intent/types.go); whichever merges second keeps both fields. Both touchpkg/satellite/reconciler.goin different functions. fix(satellite): render volume definition disk options the way LINSTOR does #275 adds row 95 todocs/cli-parity-known-deltas.md, so this PR uses 96.api/v1alpha1/resource_types.goand a mapping inpkg/store/k8s/resources.go; this PR addsapplyFailureto the sameResourceStatusstruct and a field tocrdToWireResource, so the second to merge keeps both and regeneratesconfig/crd/bases/blockstor.org_resources.yamlwithmake manifests.pkg/rest/volume_definitions.goelsewhere; the new REST code lives in its own file,pkg/rest/vd_resize_wait.go, and the handler change is a few lines.reconciler.go; the retried resize also reruns the LUKS mapper resize, which is idempotent.Testing
make lint-config && make lint: 0 issues.go test ./...with envtest assets for Kubernetes 1.35, including the provenance guard inpkg/naming/guard_test.go.make manifestsregenerated the Resource CRD.WARN_NOT_CONNECTED, and so are an evicted node, a node in another connection state, one with no status and one that cannot be read; a replica cut off from a diskful peer is not waited for and is named inWARN_NOT_CONNECTED, while one cut off only from a diskless peer is; a diskless replica with a stale size and a replica that never reported are not waited for; a caller that disconnects ends the wait; golinstor'sModifyVolumeDefinitionreturns an error when the server stops during the wait; a replica whose pass failed at the new size ends the PUT with its error, one that failed at the old size does not; the satellite records and clearsstatus.applyFailureand the store maps it; a grow extends the backing to the size plus the DRBD metadata, including an adopted volume whose old backing already held the new net size; the gross size leaves the net size for data at every size tested and is not below LINSTOR's for seven peers; a pass reports the new size only once the device reads it, and keeps the old one while the device cannot be read or is short; a replica whose backing is at size but whose applied size lags runsdrbdadm resizewithout extending the backing, stops after three passes that did not grow the device, and still reports the size once a peer grows it; one at size or without a report does not resize; a pass that left a grow short is repeated; the satellite stamps it into status, the dispatcher carries it into the desired volume and the store maps it into the REST layer; the activity-log repair message; the CLI flags reach the store and select the named file and context.Known limitations
Not tested
dfin the pod without a restart, is the check that would confirm the fix end to end.