Skip to content

fix(rest): answer a resource create once the replicas it made are ready - #291

Merged
Andrei Kvapil (kvaps) merged 27 commits into
mainfrom
fix/attach-latency
Nov 24, 2026
Merged

Andrei Kvapil (kvaps) merged 27 commits into
mainfrom
fix/attach-latency

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Stacked on #277: this branch is based on fix/satellite-new-resource-latency, so review only the commits above it, and merge #277 first.

What this PR does

A new replicated volume took about 70 seconds from claim to attach on a 3-node cluster with roughly 380 replicas. The logs put the time in two places, and this PR removes both.

Controller allocation, about 20 seconds. Autoplace wrote the three Resources two seconds after the claim was created, and the satellites then logged waiting for controller-side DRBD-ID allocation for another 18 to 21 seconds. The controller's resource reconciler has one worker and no filter on its Resource watches. A watch over the idle cluster showed about 7.6 Resource writes a second, every one a status apply that changed no value, only the resourceVersion and the managed-fields entries. Each of them queued the replica and its siblings, and every reconcile then read the Resource and its definition past the cache under the process-wide allocation lock, even for replicas allocated long ago. A new Resource waited behind all of that for its node id, port and minor.

  • The resource controller now drops an update whose objects differ only in resourceVersion and managed fields. Spec, status, metadata changes and the informer resync still pass. This is the controller side of what fix(satellite): reconcile a new resource within seconds on a busy node #277 did for the satellite's sibling watch.
  • The allocator returns early when the cached Resource and definition already carry every identity it would write. It never rewrites a value once set, so the uncached reads and the lock are kept for replicas that still need one.

CSI attach backoff, about 30 seconds. LINSTOR answers a resource create or an autoplace only after its satellites brought the new resources up and, within 15 seconds, reported them ready (CtrlRscCrtApiHelper.deployResources and waitResourcesReady). linstor-csi relies on that: ControllerPublishVolume reads the volume's device path right after CreateVolume and fails with could not determine device path while there is none. blockstor answered as soon as the Resources were written, so the first publish ran before anything was built and the attacher retried after 1, 4, 8, 16 and 32 seconds. The last retry, not the satellites, decided when the pod got its volume. linstor-csi makes this worse: it reads replicas through a cached copy of /v1/view/resources (golinstor cache.ResourceCache, --resource-cache-timeout, 30 seconds by default), refilled after its own writes. An answer that comes before the device path exists has the cache refilled without it, and every publish retry for the next 30 seconds reads that copy. This holds for linstor-csi v1.11.2, the version on the test cluster, whose attach makes no write when the replica already exists. From v1.11.3 the attach calls make-available on every attempt, which resets the cache, so the effect is smaller there; the first publish still needs an answer that comes after the build.

  • Autoplace, spawn, make-available when it creates a replica, the explicit resource create (POST .../resources and POST .../resources/{node}, the call linstor-csi's Manual scheduler makes) and the snapshot restore (POST .../snapshot-restore-resource) now wait in LINSTOR's two steps, as all of them go through LINSTOR's deployResources. A make-available that only changes an existing replica answers at once, as in LINSTOR. First they wait until the satellites built every replica the call deployed: each volume has its device path, after mkfs when a filesystem was asked for, and for a diskless replica its DRBD device. This is LINSTOR's updateSatellites, which waits for each satellite to answer the update and runs for every definition, local volumes and single replicas included. Then they wait up to LINSTOR's 15 seconds for the replicas to become ready, and add LINSTOR's per-node not-ready warning for any that did not. The placement stands either way.
  • The snapshot restore awaits every node it names, not only the replicas this call stamped, since a resumed restore's replicas may not be built yet either. The replay of a finished restore waits the same way: a restore counts as finished once its replicas are written, so a client that gave up during the first answer's wait would otherwise get its retry answered at once over a replica that is not built. A bare restore that names no node places nothing in blockstor and answers at once; the clone, whose progress linstor-csi polls on its own endpoint, is unchanged. linstor-csi restores a volume onto the node its consumer is scheduled to and autoplaces the other replicas after this answer, and that autoplace waits only for what it placed, so before this the replica the attach reads was the one replica of a restored volume nothing waited for.
  • The build step has a bound LINSTOR does not have, 30 seconds: a LINSTOR satellite answers a failed apply with an error, while a blockstor satellite reports nothing to the REST layer. A replica not built by then gets the not-ready warning and the ready step is skipped. The bound is sized so that it and the 15 second ready bound fit in the one minute timeout piraeus-operator gives csi-provisioner and csi-attacher, with room left for the writes before them; a longer bound had the sidecar cancel a slow CreateVolume and start it over instead of getting the warning.
  • What is awaited follows LINSTOR v1.33.1. Only the replicas this call created or promoted from a witness are awaited, so an autoplace that finds its target already met answers at once, even when an existing replica is degraded. INACTIVE replicas and replicas on a node that is not ONLINE are not awaited in either step. Every replica of the definition on a node that is not ONLINE, deployed by this call or not, gets LINSTOR's not-connected warning, whatever the layers or the replica count and also when the build step ran out of time, as LINSTOR's updateSatellites gives it for each satellite it cannot reach. A deployed replica on such a node is warned once, where LINSTOR may warn it a second time from waitResourcesReady. The ready step is skipped for a definition with no volume, a single replica, no DRBD layer, or only diskless replicas. A deployed diskless replica is awaited like a diskful one.
  • Ready is LINSTOR's ResourceState.isReady: every volume reaches UpToDate data, locally or through a connected UpToDate peer, and the replica is connected to every diskful peer on an ONLINE node. A diskful replica must also report its device path, because blockstor learns the path from the satellite while LINSTOR has it in its layer data from the start.
  • Two deliberate differences from LINSTOR, both in the direction of waiting less: peers that are being deleted are not expected to connect, and the peer's UpToDate state is read from the peer's own report rather than from the waiting replica's view of it.
  • The satellite now reports /dev/drbd<minor> as the device path of a diskless DRBD replica, as LINSTOR does. Before, a diskless replica had no device path at all, so a remote attach (linstor-csi's make-available on a node without a replica) failed with could not determine device path on every attempt, not just the first.
  • The placer gains PlaceDeployed, which also returns the nodes the call deployed to; Place and its other callers are unchanged, and spawn now uses PlaceDeployed.
  • Both steps keep in view the replicas the call just wrote, and its volumes. They read the replicas and volume definitions from this apiserver's informer cache, which trails the writes the same request made a few milliseconds before. A deployed replica the cache did not list yet was skipped as if deleted meanwhile, and a definition whose volumes the cache did not list yet was answered as one without volumes. Either way the call was answered at once; for a single local replica, which has no ready step after the build, nothing held the answer at all. When the cache lacks a deployed replica, or lists no volume, the waits now read the API server, so a replica is skipped only when it is really gone. LINSTOR answers from the objects it just created and cannot miss one. If that read fails, on a timeout or a throttled request, the replica counts as not built and not ready and the bound decides, with the failure logged once per wait, instead of the wait ending as if nothing were pending. The not-connected warning reads the same view, so a replica just deployed on a node that is not ONLINE is warned even before the cache lists it. A deployed replica the API server confirmed gone is not read past the cache again for the rest of the wait.
  • The build bound holds for one CreateVolume, not for one request. linstor-csi places a volume in two calls, the replica on the preferred node first and the rest after it, and each call waiting the whole bound took two bounds plus the ready wait, past csi-provisioner's minute when the satellites were slow; the sidecar cancelled the create and linstor-csi began deleting the volume it was making. The second call's bound now ends 30 seconds after the first replica of the same create was placed, read off the replicas' creation times because the two calls may reach different apiserver replicas, and read from the API server when this replica's cache does not list the first one yet. A replica placed more than a minute ago belongs to no create in flight, and make-available keeps the whole bound, as ControllerPublishVolume has a minute of its own.
  • A zero wait keeps the old behaviour for unit tests and the integration harness, which run no satellite; both binaries set the LINSTOR value for the ready step and 30 seconds for the build step.

Seen on the test cluster after the first version of this PR

With the ready wait alone, most new volumes attached 1 to 2 seconds after CreateVolume, but a pod with a replicated and a local Block volume waited about 100 seconds. The REST log shows the replicated autoplace answered after 15.2 seconds, at the bound: the controller allocated the DRBD ids 16 seconds after placement, so nothing was built yet. DRBD was up 4 to 5 seconds after that answer and connected on all three nodes within 15 seconds, but ControllerPublishVolume failed on its attempts 2, 3, 7, 15 and 31 seconds after the answer, all within 30 seconds of the refill that followed it, and succeeded on the attempt 63 seconds after it, the first one after linstor-csi refilled its view again. The local Block volume, created at the same time and never awaited, attached on the same retry. A local Filesystem volume was refused five times until its mkfs finished. With the build step every one of these answers comes after the device path exists, and the first publish finds it.

Seen on the test cluster with v0.4.0-alpha.6

With both steps deployed, a new local Filesystem volume was still refused five times with could not determine device path over 10 seconds and attached 19 seconds after it was provisioned. The REST log shows its autoplace answered in 112 ms, on the same apiserver replica that had served the volume definition write and a cached read of it just before, so the volumes were in view and the replica the autoplace had just written was not. The satellite built the zvol and reported its path afterwards. The same pattern shows in a burst of 16 replicated claims, where 11 of the 32 autoplace calls answered in 66 to 168 ms. A local Block volume whose autoplace answered after 1.6 seconds attached on the first try.

v0.4.0-alpha.6 carries this PR up to the build step. The cache fallback and the shared build bound came after it and are not in that release; they need their own way into the next one.

Seen on the test cluster with v0.4.0-alpha.10

A volume restored from a snapshot while its source was still in use waited 102 seconds for its pod, against about 30 for the other restores of the same run. linstor-csi restored it onto the node the pod was scheduled to, answered at once, and autoplaced the two other replicas, whose autoplace waited 14 seconds for them. The restored replica itself was not awaited. Its DRBD resource came up after its autoplaced peers, and ControllerPublishVolume on that node failed with could not determine device path on all seven attempts from the moment CreateVolume returned until 29 seconds later; the attacher's next retry, 32 seconds after that, succeeded. With the restore awaited, linstor-csi's autoplace starts only once the restored replica is built, so the publish after CreateVolume finds its device path.

Interactions

Not addressed

  • The status writes that change no value still happen on the satellites; this PR stops them from reaching the controller, it does not stop them being written. On the test cluster, a 10-second sample showed 66 of 379 Resources with a new resourceVersion where spec, status, metadata and every managed-fields entry's fields were unchanged, and only the time of the blockstor-satellite and blockstor-satellite-volume-status status managers moved, along with the order of the managed-fields entries. That needs its own fix on the satellite side.
  • A bare snapshot restore that names no node leaves an empty definition in blockstor and answers at once, where LINSTOR v1.33.1 restores onto the snapshot's nodes and waits for them. That difference predates this PR and is not changed here.
  • An autoplace that places nothing still answers with the usual "auto-placed" info entry rather than LINSTOR's "already deployed on N nodes. Skipping."

Testing

  • make lint-config && make lint: 0 issues.
  • go test ./... with envtest assets: pass, including the provenance guard in pkg/naming.
  • Full go test -tags=integration -timeout 45m ./tests/integration/ on the final head: pass, except TestGroupKWFHappyPath (Snapshot wf-happy.snap-1 not created), which fails the same way on the previous head of this branch, so it is not this change. A rerun of the area (TestGroupKWF|TestGroupCRG|TestSmoke|MakeAvailable|Diskless) also hit the known TestGroupFRToggleDiskful2DisklessReapsTieBreaker flake.
  • The three cache tests also on a throwaway copy of dev/v0.4.0-alpha.6: they fail there, and pass with the two commits picked on top, together with the rest of pkg/rest.
  • Each fix to the cache fallback was mutation-checked: removing it fails the test written for it.
  • go test -race -count=3 over the wait, autoplace, make-available and spawn tests in pkg/rest: pass.
  • go test -tags=integration ./tests/integration/... -run 'TestGroupCRG|TestGroupKWFAutoPlace|TestGroupKWFSpawn|TestGroupEVD|TestSmoke|MakeAvailable|Diskless' on the final head: pass. Earlier, for the ready wait, the full go test -tags=integration ./tests/integration/...: pass, except TestGroupFRToggleDiskful2DisklessReapsTieBreaker, which times out waiting for the autoplace's two diskful replicas in some runs. It fails the same way on the base branch (fix(satellite): reconcile a new resource within seconds on a busy node #277) in 2 of 10 isolated runs, so it is an existing flake and not this change.
  • For the snapshot restore wait: make lint-config && make lint 0 issues, go test ./... with envtest assets pass, and go test -tags=integration ./tests/integration/... -run 'Restore|Snapshot|Clone' pass. The two restore tests fail on a throwaway copy of dev/v0.4.0-alpha.10 and pass there with the commit picked on top, together with the rest of pkg/rest (the pick has a comment-only conflict there). Mutation-checked: awaiting no node fails the bound test. For the replay wait: make lint-config && make lint 0 issues, go test ./... with envtest assets pass, the full go test -tags=integration ./tests/integration/... pass; both replay tests fail with the source of the previous head and pass with the fix.
  • New tests, each failing without its fix:
    • a reconcile of an allocated replica makes no uncached read (it made 2 before);
    • the controller watch filter drops a write that changed only resourceVersion and managed fields and passes every real change;
    • an autoplace answers only after a stand-in satellite reports the replicas ready, and not as soon as it reports the device paths;
    • an autoplace of a local volume, and the explicit create of one, answer only after the stand-in satellite reports the device path (both answered at once before);
    • a replicated autoplace whose build outlasts the ready bound answers after the device paths exist, without warnings (it answered at the bound, without them, before);
    • a local replica that is never built is answered at the build bound with the not-ready warning, scaled down in the test;
    • the build bound and the ready bound together leave at least 15 seconds of the sidecars' one minute timeout (failed at 60 seconds);
    • what counts as built: a device path on every volume, for a diskless replica as for a diskful one, where a disk state alone counted for a diskless replica before;
    • a diskless DRBD replica's apply reports /dev/drbd<minor> for every volume (it reported nothing before);
    • make-available on a node without a replica answers only after the stand-in satellite built the diskless replica, and a spawn only after the placed replica is built (both answered at once before);
    • the not-connected warning for a single replica and for a replica without DRBD on a node that is not ONLINE, and next to the not-ready warning when the build bound runs out, for a replica this call did not deploy (none of them was given before);
    • an autoplace whose replica never becomes ready answers within the bound with the not-ready warning for that node only;
    • an autoplace that places nothing answers at once with no warning, and one that adds a replica waits only for that replica;
    • a create on a single node answers only after that replica is ready;
    • the predicate: no wait for a single replica, a definition without DRBD or an INACTIVE replica; the not-connected warning at once for a node that is not ONLINE; a wait for a deployed diskless replica and for a diskful one missing its peer connection; a diskless replica is ready through a connected UpToDate peer;
    • a local replica the cache does not list yet is still awaited until its device path exists, the same for a replicated definition in the ready step alone, and a definition whose volumes the cache does not list yet is still awaited (all three answered at once before);
    • when the read past the cache fails as well, the build step and the ready step still wait for the replicas, and a replica that is never listed is answered at the bound with the not-ready warning (all answered at once, clean, before);
    • the not-connected warning for a replica on a node that is not ONLINE that the cache does not list yet, and for one that cannot be read at all (no warning before);
    • a deployed replica deleted during the wait is read past the cache once, not on every poll (28 reads before, in the test);
    • the second placement of a create counts its build bound from the first replica, also when the cache does not list that replica yet (a whole bound before), a placement next to a replica older than a minute gets the whole bound, and make-available right after a create gets the whole bound;
    • the placer reports only the replicas it created, promoted or added as diskless, and nothing when the target was already met.
    • a snapshot restore onto a node answers only after the stand-in satellite reports the restored replica's device path, and a restored replica that is never built is answered at the build bound with the not-ready warning (both answered at once, without a warning, before);
    • the replay of a finished restore whose replica is not built yet answers only after the stand-in satellite reports its device path, and at the build bound with the not-ready warning when it is never built (both answered at once, without a warning, before).

Not tested

  • The cache fix is not deployed to a cluster yet; the case above was read from the REST and linstor-csi logs of v0.4.0-alpha.6, and the first field case was measured with the ready wait alone, and the linstor-csi cache was read from its source (v1.11.2 and v1.11.3, golinstor v0.64.0) and the REST request log, not traced inside linstor-csi.
  • A remote attach through a diskless replica was not run anywhere but the unit tests: the test cluster has no diskless replicas.
  • The integration harness runs no satellite and a zero wait, so it does not exercise either step.
  • The snapshot restore wait is not deployed to a cluster yet; the case above was read from the linstor-csi log, a DRBD status watch and one satellite log of v0.4.0-alpha.10. The logs of the satellite on the attach node were gone by the time it was examined, so why that replica came up after its peers was not traced on the node itself. The fix assumes the restored replica can be built before its peers exist; the field timing fits that, as it was connected about 25 seconds after the restore, inside the 30 second bound. If its slow step turns out to depend on the peers, which are placed only after the restore answers, the restore would spend the whole build bound and answer with the not-ready warning, and the attach would still back off. A restore whose source is still in use should be measured again once this is deployed.

Satellites write Resource status with server-side apply. An apply
that leaves every value as it was can still move a field manager's
entry, which is a real write with a new resourceVersion. An idle
test cluster with about 380 replicas produced several such writes a
second, all of them changing nothing but the managed fields.

The resource controller watched Resources with no filter and runs a
single worker, so each of those writes queued the replica and every
sibling. A Resource created by autoplace then waited about twenty
seconds behind them for its DRBD node id, port and minor, and the
satellites cannot build a replica before those exist.

Drop an update whose objects differ only in resourceVersion and
managed fields. Spec, status, metadata and the informer resync still
pass.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Every reconcile of a Resource ran the DRBD identity allocator first,
and the allocator read the Resource and its definition past the cache
under the process-wide allocation lock even when every identity was
set long ago. That is nearly every reconcile, and with one worker
and a few hundred replicas those round trips decided how long a new
Resource waited for its node id, port and minor.

The allocator never rewrites a value once it is set, so when the
cached Resource and definition already carry all of them there is
nothing to read again. Return early in that case and keep the
uncached path for replicas that still need a value.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR answers an autoplace only after its satellites applied the
new resources and, within fifteen seconds, reported them ready.
linstor-csi depends on that: ControllerPublishVolume reads the
volume's device path right after CreateVolume returned and fails the
attach while there is none.

blockstor answered as soon as the Resources were written. On the test
cluster the first ControllerPublishVolume ran two seconds after the
claim was created and failed with "could not determine device path",
and the attacher retried after 1, 4, 8, 16 and 32 seconds. The
replicas were built well before the last retry, which still decided
when the pod got its volume.

Wait for every diskful replica on a reachable node to report a device
path for every volume, up to LINSTOR's fifteen seconds, and answer
with LINSTOR's not-ready warning for the ones that did not. A zero
wait keeps the old behaviour for unit tests that run no satellite;
both binaries set the LINSTOR value.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR's autoplace waits for the resources the call created, its
deployedResources, and answers an autoplace that found the target
already met without waiting at all. Place only reported counts that
include the replicas already there, so a caller could not tell what
this call added. PlaceDeployed also returns the nodes it created a
replica on or promoted a witness on; Place keeps its signature.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The autoplace wait covered every diskful replica of the definition
and called a replica ready once it had a device path. LINSTOR v1.33.1
(CtrlRscCrtApiHelper.waitResourcesReady) waits only for the resources
the call deployed, so an autoplace that places nothing answers at
once; a degraded existing replica held every CreateVolume retry on
such a volume for the full 15 seconds and earned a warning about a
replica the call never touched.

Follow LINSTOR's predicate as well: no wait for a single replica, a
definition without DRBD or an all-diskless one; skip INACTIVE
replicas; answer a replica on a node that is not ONLINE with the
not-connected warning instead of waiting; wait for a deployed
diskless replica too. Ready is ResourceState.isReady: UpToDate data,
locally or through a connected UpToDate peer, and a connection to
every diskful peer on an ONLINE node. A blockstor satellite reports
the device path right after apply, before DRBD connected, so the path
alone answered earlier than LINSTOR does; it is still required for a
diskful replica, because blockstor learns it from the satellite.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR answers POST .../resources through the same deployResources
as an autoplace, so it waits for the new replicas there too. That is
the call linstor-csi's Manual scheduler makes for a CreateVolume with
a fixed node list; answering it at once left that path with the same
ControllerPublishVolume "could not determine device path" retries the
autoplace wait removed.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e651f74f-d46b-433c-bf68-3761705677d1
Commits

Reviewing files that changed from the base of the PR and between 3f511fe and 3c512bc.

Files selected for processing: 23

  • cmd/apiserver/main.go
  • cmd/controller/main.go
  • internal/controller/export_test.go
  • internal/controller/resource_controller.go
  • internal/controller/resource_watch_filter_test.go
  • internal/controller/settled_identities_test.go
  • pkg/placer/deployed_test.go
  • pkg/placer/placer.go
  • pkg/rest/autoplace.go
  • pkg/rest/autoplace_cache_lag_test.go
  • pkg/rest/autoplace_deploy_test.go
  • pkg/rest/autoplace_ready.go
  • pkg/rest/autoplace_ready_test.go
  • pkg/rest/create_build_deadline_test.go
  • pkg/rest/server.go
  • pkg/rest/snapshot_restore.go
  • pkg/rest/snapshot_restore_deploy_test.go
  • pkg/rest/spawn.go
  • pkg/rest/vd_resize_wait.go
  • pkg/satellite/reconciler.go
  • pkg/satellite/reconciler_drbd_test.go
  • tests/e2e/observability-capacity-correlation.sh
  • tests/e2e/recovery-port-collision.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

LINSTOR's deployResources first waits for every satellite to answer
the update, which a satellite does once it built the resource, and
only then starts the 15 second wait for the resource to become ready.
blockstor ran both under one 15 second bound counted from placement,
and skipped the wait for local volumes and single replicas.

linstor-csi reads replicas through a cached resource view that it
refills after its own writes and otherwise keeps for 30 seconds. When
allocation and the build outlasted the bound, or for any local volume,
CreateVolume returned before the device path existed, the view was
refilled without it, and ControllerPublishVolume kept failing with
"could not determine device path" until the cache expired; the
attacher's backoff then put the attach a minute after the device was
up.

Wait for the device path of every deployed diskful replica, or the
observed disk state of a diskless one, for every definition, before
the ready wait. A satellite reports no failed apply, so this step is
bounded at 60 seconds and answers with the not-ready warning.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A remote attach goes through make-available, which creates a diskless
replica on the consumer's node, and linstor-csi's
ControllerPublishVolume then reads that replica's device path from the
resource view. The satellite stamped no path for a diskless replica,
so the view never had one and every attach attempt failed with "could
not determine device path". LINSTOR reports /dev/drbd<minor> for a
diskless volume as for a diskful one; report the same.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi reads the device path of the replica it attaches to right
after make-available or a create returned. The build wait took a disk
state as enough for a diskless replica, which the observer can report
before the apply pass that stamps the path ends, so the answer could
still precede the path linstor-csi needs. Now that the satellite
reports the DRBD device of a diskless replica, require the path for
every replica, diskless or not.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR's updateSatellites answers a create or autoplace with the
not-connected warning for each replica of the definition whose
satellite it cannot reach, whatever the layers or the replica count.
blockstor gave that warning only from the ready step, so a local
volume, a single replica or a build that ran out of its bound was
answered without it, and a replica on an offline node that this call
did not deploy was never named. Collect the warning up front for
every replica of the definition and keep it in every answer.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
piraeus-operator runs csi-provisioner and csi-attacher with
--timeout=1m. A 60 second build bound plus the 15 second ready bound
outlasted that minute, so a slow build was cut off by the sidecar,
whose retry started over, instead of answered with the not-ready
warning. 30 seconds leaves a quarter of the minute for the writes in
front of the waits.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR creates the replica of a make-available on a node without one
through createResource, so the call returns after deployResources saw
the satellite build it. linstor-csi's ControllerPublishVolume reads
the device path right after make-available on a remote attach, so
answering at once failed the first attempt and left the attach to the
attacher's backoff. A replica the call only changed is not awaited,
as in LINSTOR.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR's spawn places through the same autoplace, so it answers after
deployResources like an autoplace does. blockstor's spawn answered as
soon as the Resources were written; it now waits for the replicas the
placement deployed, in the same two steps.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A new local volume was answered in about 100 ms, before its satellite
built it, and linstor-csi refused ControllerPublishVolume five times
with "could not determine device path" until its retry read a view
that had the path.

The build and ready waits read the replicas from this apiserver's
informer cache, which trails the writes the same request made a few
milliseconds earlier. A deployed replica the cache did not list yet
was skipped as if deleted meanwhile, so a single replica without DRBD,
which has no ready step after the build, counted as built at once.
LINSTOR answers from the objects it just created and cannot miss one.

When the cache lacks a deployed replica, the waits now list the
replicas from the API server, so the replica is awaited unless it is
really gone.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi writes the volume definitions right before the autoplace
or the create, through whichever apiserver replica the Service picks.
When the replica serving the placement had not seen them in its cache
yet, the waits found no volume and answered as for a definition
without volumes, before the satellite built anything, which leaves
ControllerPublishVolume without a device path the same way.

An empty cached listing is now checked against the API server before
the waits give up on the volumes.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi places a volume in two calls inside one CreateVolume: the
replica on the preferred node first, the remaining replicas after it.
Each call waited up to the whole deploy bound for the satellites, so
two slow builds plus the ready wait took the whole minute
csi-provisioner gives a create. The sidecar cancelled it and
linstor-csi began deleting the volume it was making.

Count the bound from the first replica of the same create instead,
read off the replicas' creation times because the two calls may reach
different apiserver replicas. A replica placed more than a minute ago
belongs to no create in flight, and make-available keeps the whole
bound: it is ControllerPublishVolume, which has its own minute.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The waits fall back to the API server when the cache does not list a
replica the call just deployed. A failed fallback read, a timeout or a
throttled request, ended both waits as if nothing was pending, so the
call answered before the device path existed and linstor-csi refused
the attach with "could not determine device path", with nothing in the
log to say why. Such a replica now counts as not built and not ready,
the bound decides, and the failure is logged once per wait.

The not-connected warning read the cache alone, so a replica deployed
on a node that is not ONLINE and not cached yet got no warning, where
LINSTOR's updateSatellites gives one. It now comes from the same view
as the waits.

A deployed replica the API server confirmed gone is remembered for the
rest of the wait instead of being read past the cache on every poll.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi's second placement call of a CreateVolume may reach an
apiserver replica whose cache does not list the replica the first call
placed. The build bound then restarted at a whole deploy wait from now,
and with the ready wait could run past csi-provisioner's minute, the
failure the shared bound exists to prevent. When the cache lists no
earlier replica, read the API server before deciding the create starts
with this call.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR answers snapshot-restore-resource after deployResources, the
same wait a resource create has. linstor-csi restores a volume onto
the node its consumer is scheduled to and only then autoplaces the
other replicas, and that autoplace waits for the replicas it placed,
not for the restored one. Answered at once, the restore left the one
replica ControllerPublishVolume attaches unawaited. On the test
cluster that replica came up after its autoplaced peers, its device
path was still missing about 30 seconds after CreateVolume returned, and
the attacher backed off seven times before the pod got the volume.

The restore now waits in the same two bounded steps as a create, for
every node it names, and adds the not-ready warning for a replica
that is not built or ready in time.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A restore counts as finished once its replicas are written, not once
the satellites have built them. A client that gave up during the
first answer's deploy wait therefore got its retry answered at once
as a finished restore, with no wait and no not-ready warning: the
same missing device path the first answer's wait was added to close.

The replay now waits for the nodes the restore names the way the
first answer does, and warns for a replica not built or ready in
time.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The e2e suite goes red with this PR. Lane 4 on the head run failed recovery-port-collision with curl exit 28: tests/e2e/recovery-port-collision.sh fires ten parallel autoplaces with curl -sf -m 10 under set -euo pipefail. An autoplace now waits for the build and the ready step (up to 30 s + 15 s), and ten 2-replica builds at once take longer than 10 s. The scenario passes on #277. Please raise that client timeout past the new bound in this PR (tests/e2e/observability-capacity-correlation.sh also caps an autoplace at 30 s, worth a look).

I checked the waits against LINSTOR v1.33.1 (DFLT_RSC_READY_WAIT_TIME_IN_MS, waitResourcesReady skip rules) and the controller-side predicate and settled-identity shortcut, and found nothing else.

An autoplace now answers once the placed replicas are built and
ready, which can take up to the 30 s build bound plus LINSTOR's 15 s
ready bound. recovery-port-collision fires ten 2-replica autoplaces at
once with a 10 s curl timeout under set -e, so the client gave up
first and the scenario failed with curl exit 28. The capacity probe in
observability-capacity-correlation expects a refusal that comes at
once, but if the gate does not fire its 30 s timeout would hide the
real answer behind a curl timeout. Both now allow 60 s.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps

Copy link
Copy Markdown
Member Author

Thanks, that was the client giving up first. Fixed in 7874641: the ten parallel autoplaces in tests/e2e/recovery-port-collision.sh now use curl -m 60, which sits past the 30 s build bound plus the 15 s ready bound from pkg/rest/autoplace_ready.go, with a comment saying why. The capacity probe in tests/e2e/observability-capacity-correlation.sh got the same 60 s: the gate refuses at once there, but if it ever does not fire, the report now shows the real answer instead of curl exit 28.

I also went through the other e2e scripts for a create or autoplace POST with a short client timeout and found none; the remaining short -m values are on GET requests, which this PR does not slow down.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The e2e timeout is fixed: both autoplace clients now wait 60 s, past the 30 s + 15 s bound, and lane 4 is green.

#277 is merged, so this PR's base branch is gone from the merge path. Please retarget it to main and rebase. Against current main it conflicts in three files. resource_controller.go (imports) and snapshot_restore.go (a comment next to stampRestoredResourcesOnNodes, which now takes the snapshot) are mechanical. placer.go is not, see inline.

Comment thread pkg/placer/placer.go Outdated
}

if err == nil {
s.deployed = append(s.deployed, pool.NodeName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Main moved this block into writeReplica (pkg/placer/placer.go on main), and an ErrAlreadyExists from the create now goes to takeOverReplicaWrittenMeanwhile instead of being skipped. A promote can also return errReplicaTerminating, which the caller treats as not placed. So the rebase has to decide where deployed is recorded: whether a replica taken over after ErrAlreadyExists counts, and that a terminating one does not. That choice sets which nodes the REST wait waits for, so please make it in the rebase, with a test for the take-over case.

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.

deployed is recorded in tryPlace after writeReplica returns, so it follows main's split. writeReplica now also reports whether it created the replica. A witness taken over, whether the placement saw it before it started or the create hit ErrAlreadyExists and takeOverReplicaWrittenMeanwhile promoted it, counts as deployed but not created: the autoplace waits for it, as LINSTOR keeps a TieBreaker it takes over in deployedResources, and a caller taking back what the call created leaves it alone. errReplicaTerminating returns before that point, so a witness being deleted is neither placed nor waited for.

Pinned in 3c512bc by TestPlaceDeployedCountsWitnessTakenOverMidPlacement: the take-over after ErrAlreadyExists deploys to all three nodes, and a terminating witness written during the placement leaves its node out. Recording deployed only on a create fails the take-over case and the existing promoted-witness case.

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

# Conflicts:
#	internal/controller/resource_controller.go
#	pkg/placer/placer.go
#	pkg/rest/snapshot_restore.go
#	pkg/satellite/reconciler.go
The wait on a resource create and the wait on a volume grow each
brought their own warnNotConnected and notConnectedWarnings into
package rest. The return code is the same LINSTOR constant, so one
declaration stays; the grow's builder keeps its definition and volume
object refs under a name of its own. Neither branch is wrong alone;
only the two together fail to build.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The allocator's layer-stack test on main and the settled-identities
test of the attach-latency branch each declare a countingReader in
package controller_test, with different fields: one counts definition
and group reads, the other every round trip. The second is renamed so
the package builds with both; neither test changes what it pins.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The main merge put partialShortfall next to shortfallError from main,
and revive refuses two receiver names on one type, which failed Lint
on this branch.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps
Andrei Kvapil (kvaps) changed the base branch from fix/satellite-new-resource-latency to main November 24, 2026 02:04
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

# Conflicts:
#	cmd/apiserver/main.go
#	cmd/controller/main.go
Main moved the replica write into writeReplica, where a create that
finds a replica written meanwhile takes it over and a replica being
deleted is refused. The merge counts a taken-over witness as deployed,
as LINSTOR's autoplace keeps a TieBreaker it takes over in
deployedResources, and leaves a terminating one out. These cases pin
that choice, since it sets which replicas the REST create waits for.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps

Copy link
Copy Markdown
Member Author

Retargeted to main. Main is merged into the branch instead of a rebase, so the history you already reviewed stays as it is: the earlier merge 85feeb8 took the placer.go, resource_controller.go and snapshot_restore.go conflicts, and 442ebe0 brings in the rest of main (only the REST server options in the two cmd/*/main.go files conflicted, both sides kept).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. The placer resolution looks right to me. deployed is recorded in tryPlace after writeReplica, so a witness taken over after ErrAlreadyExists is waited for and a terminating one is not. That matches linstor-server v1.33.2, where every selected pool goes through createResourceDb into deployedResources, a taken-over TieBreaker included (CtrlRscAutoPlaceApiCallHandler.java L421-443). The new test covers both cases. The other post-merge commits only fix duplicate names between the two branches.

@kvaps
Andrei Kvapil (kvaps) merged commit 7090d5c into main Nov 24, 2026
16 checks passed
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