Skip to content

fix(controller): take auto-snapshots on LINSTOR's schedule - #301

Merged
Andrei Kvapil (kvaps) merged 8 commits into
mainfrom
fix/auto-snapshot-cadence
Nov 24, 2026
Merged

Andrei Kvapil (kvaps) merged 8 commits into
mainfrom
fix/auto-snapshot-cadence

Conversation

@kvaps

Copy link
Copy Markdown
Member

What this PR does

With AutoSnapshot/RunEvery 1 the controller took one auto-snapshot every two minutes instead of every minute. The runnable polled once a minute and started the next interval at the moment the poll ran, so a poll that arrived a few milliseconds before the minute was up found nothing due and the snapshot waited a whole extra poll.

The runnable now schedules the way LINSTOR's AutoSnapshotTask does: it polls every ten seconds, and each snapshot is booked at the slot that fell due (previous slot plus RunEvery), not at the moment the poll noticed it, so poll delay never adds up across intervals. When a slot was missed by a whole interval or more, for example while the controller was down, the snapshot is booked at the time it is taken instead of catching up slot by slot, which would only rotate older snapshots out of the AutoSnapshot/Keep budget. This part deliberately differs from LINSTOR: LINSTOR keeps its schedule in memory and after a restart books the first snapshot at start plus RunEvery plus one poll, while blockstor keeps the slot in the definition's annotation, so a leader failover shorter than RunEvery does not shift the schedule. The annotation now holds that slot rather than the creation time, so it can read up to one poll earlier than the Snapshot's creationTimestamp.

Release note

fix(controller): `AutoSnapshot/RunEvery` takes one snapshot per interval, as LINSTOR does; `RunEvery 1` no longer takes one every two minutes.

Testing

  • New unit test drives the runnable with one tick per poll period and up to half a second of jitter either way for 30 minutes of RunEvery 1, and checks after every tick that each minute's snapshot was taken by the first poll at or after it (31 snapshots in total). It fails with the old one-minute poll (3 snapshots after 3 minutes, want 4), with intervals counted from the poll time (same), and with both (the shipped behaviour).
  • New unit test: a definition whose last auto-snapshot is three hours old gets exactly one snapshot in the following minute, not one per poll. It fails when missed slots are caught up.
  • The same tests pass on top of the combined dev/v0.4.0-alpha.6 branch, with that branch's replica fixtures, and fail there with the old scheduling.
  • make lint-config && make lint: 0 issues. go test ./... passes. Integration TestGroupG passes.

Not tested

  • Not run on a live cluster yet. The behaviour was seen on a test cluster running v0.4.0-alpha.6: controller logs show auto-snapshots created at 20:28:51, 20:29:52, 20:31:53, 20:33:52 and 20:35:51 for RunEvery 1, each take finishing within two seconds.

AutoSnapshot/RunEvery 1 produced one snapshot every two minutes. The
runnable polled once a minute and counted the next interval from the
poll that took the snapshot, so a poll that arrived a few milliseconds
short of the minute found nothing due and the snapshot waited for the
following poll.

LINSTOR's AutoSnapshotTask polls every ten seconds and books each run
at the slot that fell due, the previous slot plus RunEvery, so poll
delay never stretches the interval. Do the same. A slot missed by a
whole interval, after controller downtime, is booked at the time it is
taken instead of being caught up one snapshot per poll, which would
only rotate older snapshots out of the keep budget.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The annotation now holds the schedule slot, not the creation time, so
an operator comparing it with the Snapshot's creationTimestamp would
see up to one poll of difference and suspect a bug.

The downtime rationale claimed LINSTOR catches up one snapshot per
poll. It does not: it keeps the schedule in memory and after a restart
starts it at start + RunEvery + one poll. Booking a missed slot at
take time is our own choice, which also keeps the slot across a
failover shorter than RunEvery.

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

coderabbitai Bot commented Nov 21, 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 50 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: 64fca5e3-15b1-4aa5-b072-35ed76709bf7
Commits

Reviewing files that changed from the base of the PR and between 5c0cdd4 and ee1442f.

Files selected for processing: 5

  • docs/cli-parity-known-deltas.md
  • internal/controller/autosnapshot_cadence_test.go
  • internal/controller/autosnapshot_controller.go
  • pkg/satellite/controllers/resource.go
  • pkg/satellite/controllers/resource_group_watch_test.go
  • 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

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.

Matches LINSTOR v1.33.1 AutoSnapshotTask: a 10 s poll (TASK_TIMEOUT) and the next run booked at the slot (AutoSnapshotConfig.next()). Keeping the slot across a restart instead of LINSTOR's start-plus-RunEvery is documented and does not catch up missed slots. LGTM.

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 schedule matches LINSTOR v1.33.1 AutoSnapshotTask: a 10 s poll (TASK_TIMEOUT) and the next run booked at the slot (AutoSnapshotConfig.next()). One repo rule is not met yet, inline.

// catch-up would take one snapshot per poll and only rotate older
// snapshots out of Keep. LINSTOR keeps its schedule in memory and
// after downtime restarts it at start + RunEvery + one poll; keeping
// the slot across a failover shorter than RunEvery is deliberate.

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.

This is an intentional divergence from LINSTOR (it books start + RunEvery + TASK_TIMEOUT after a restart, AutoSnapshotTask.java:104 in v1.33.1, while blockstor keeps the slot in the annotation), and the PR body says so too. CLAUDE.md asks for every intentional divergence to get a row in docs/cli-parity-known-deltas.md, and the PR adds none. Please add a BEHAVIOR row for the auto-snapshot schedule after a controller restart or failover.

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.

Agreed, added in 9c52ff6: row 100 in docs/cli-parity-known-deltas.md, BEHAVIOR, permanent. It describes LINSTOR's start plus RunEvery plus one poll after a restart (AutoSnapshotTask.java in v1.33.1) against blockstor keeping the slot in the annotation, notes that a slot missed by a whole interval is booked at the take time with no catch-up, and points to the two cadence tests that pin it. The id skips 95 to 99, which other open branches already use.

On the red Unit tests and Integration tests runs of this head: TestReconcileComesBackWhenAPlacementHoldRunsOut and TestManagerIndexesCachedReplicasByDefinitionKey fail the same way on main at bd9d4df (run 45202362404), and TestGroupKWFHappyPath failed on main at 1e095f3 too (run 45171569631). None of them touches the auto-snapshot path; the cadence tests pass.

The PR keeps the auto-snapshot slot in the definition's annotation, so
a restart or a leader failover shorter than RunEvery does not shift
the schedule, while LINSTOR v1.33.1 rebooks the first run at start
plus RunEvery plus one poll. That is an intentional divergence, and
every intentional divergence gets a row in the accept-list. The id
skips the rows other open branches already use.

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.

Row 100 covers the restart divergence, which was my only point. I rechecked the schedule against AutoSnapshotTask at v1.33.2: same TASK_TIMEOUT, same first-run booking, same next(). The red unit and integration tests fail the same way on main.

The cadence tests take auto-snapshots of a definition with no replicas
and never finish a take. #292 targets an auto-snapshot at the
definition's diskful replicas, skips a tick without one, and holds a
tick back while the previous take still has I/O suspended, so with
both branches merged the tests took no snapshot after the first. They
now give the definition its replicas and finish each take, with
helpers of their own so the file builds with or without #292.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Several open branches added accept-list rows at the next free id on
main, so the merged table carried
ids 95, 96, 97 and 100 twice. Each branch
now takes its own ids above main's 98, in PR order, so they stay
unique whatever order the branches merge in. This row moves from 100
to 106.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
prealloc failed Lint on the new withCadenceReplicas helper, whose
length is known up front.

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.

LGTM. Re-approving. The cadence tests keep their expected counts; the new helpers only give the definition diskful replicas and finish each take, which is what #292's target and in-flight checks need, and they are inert without #292. Row 106 is free on main and in the other open branches.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The volume definition disk options and the render-input wake-ups both
added a ResourceGroup watch to the replica reconciler, each mapping a
group event to this node's replicas of the group's definitions. With
two handlers for one event, the pass was counted under whichever
enqueued first, so a group edit was sometimes reported as a definition
change rather than a configuration one, and the render-input test
that waits for the latter timed out. The render-input watch covers
the same replicas, so the older one goes and its test now checks the
mapper that remains.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps
Andrei Kvapil (kvaps) merged commit 6a0d243 into main Nov 24, 2026
7 of 9 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