Skip to content

fix(rest): answer a snapshot create once the snapshot is listed - #284

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
fix/integration-flakes
Nov 23, 2026
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
fix/integration-flakes

Conversation

@kvaps

Copy link
Copy Markdown
Member

What this fixes

TestGroupJ/CSIListSnapshotsPagination failed on loaded CI runners with page2: got 1 entries, want 2. The test creates four snapshots and pages through GET /v1/view/snapshots two at a time right away, the way csi-snapshotter pages through ListSnapshots after CreateSnapshot. blockstor answered the snapshot create as soon as the Snapshot object reached the apiserver, while the list is served from the informer cache. When the cache had not yet seen the last create, the second page came back short, and a short page reads as the end of the list.

LINSTOR answers the create after the snapshot definition is in its database, so the s l that follows lists it. The create now waits, within the same budget the delete paths already use to make their result visible, until the local store returns the new snapshot. Running out of budget still answers success, since the write committed.

Changes

  • POST /v1/resource-definitions/{rd}/snapshots waits until the created snapshot is readable from the local store before it answers.
  • A unit test with a store that hides a created snapshot for a short while pins that the list issued right after the create includes it. It fails without the change.

Other integration failures looked at

  • TestGroupFRToggleDiskful2DisklessReapsTieBreaker and TestGroupFRAutoPlace2ReachesUpToDate (diskful replica count never reaching 2) are not fixed here. rd c lazily creates DfltRscGrp, and the RG reconciler then runs the placer on every definition in that group. When it gets to a fresh definition after its volume definition exists but before the test's r c --auto-place 2 --storage-pool lvm-thin, it places one replica on any pool, for example file, and the explicit auto-place can no longer add an LVM_THIN replica next to it. LINSTOR places nothing on an RG event. fix(controller): keep rebalance from re-placing a definition whose replicas were deleted #280 makes the RG reconciler skip definitions with no UpToDate replica, which removes this; with it the test passed 30 runs out of 30, against 1 to 2 failures in 30 on main.

LINSTOR answers `POST .../snapshots` after the snapshot definition is
in its database, so the `s l` that follows lists it. blockstor wrote
the Snapshot to the apiserver and answered at once, while the list is
served from the informer cache, which sees the create only when the
watch event arrives. csi-snapshotter pages through ListSnapshots right
after creating, and a page that comes back short reads as the end of
the list; TestGroupJ/CSIListSnapshotsPagination caught exactly that
on a loaded CI runner ("page2: got 1 entries, want 2").

The create now waits, within the same budget the delete paths use,
until the local store returns the new snapshot. Running out of budget
still answers success, since the write committed.

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

coderabbitai Bot commented Nov 19, 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 47 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: 7cad29be-0311-4f43-968f-45a84727e91b
Commits

Reviewing files that changed from the base of the PR and between 216e577 and d4a0b46.

Files selected for processing: 3

  • pkg/rest/cache_invalidation.go
  • pkg/rest/snapshot_create_visible_test.go
  • pkg/rest/snapshots.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.

The wait uses the same Snapshots().Get(rd, snap.Name) key as the duplicate check above it, so a create that is visible returns right away and the 5 s budget only applies while the cache trails. Running out of budget still answers 201 because the write committed, which is right. The test hides the snapshot from both Get and List, so it fails without the wait.

//
// The budget running out is not an error: the write committed, and the
// next read catches up as it did before this wait.
func (s *Server) waitForSnapshotCreateVisible(ctx context.Context, rdName, snapName string) {

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.

Non-blocking. This waits on this replica's informer. With apiserver running as a 3-replica Deployment behind a Service, csi-snapshotter's next ListSnapshots page can land on a replica whose cache has not seen the create yet, so a short page is still possible in production. Fine for the integration flake this targets; it may deserve a line in the comment.

@kvaps
Andrei Kvapil (kvaps) merged commit 932e692 into main Nov 23, 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