Skip to content

Disable VolumeSnapshot-based replica creation - #66

Merged
deverts merged 3 commits into
mainfrom
xata/disable-volumesnapshot-replicas
May 28, 2026
Merged

deverts merged 3 commits into
mainfrom
xata/disable-volumesnapshot-replicas

Conversation

@deverts

@deverts deverts commented May 26, 2026 •

Copy link
Copy Markdown
Member

Replica PVCs were being hydrated from a VolumeSnapshot whenever a recent snapshot-backed backup or a bootstrap snapshot was available. Our storage backend confines a snapshot child to its parent's storage node, so a snapshot-sourced replica can never honor anti-affinity placement. This PR closes that path: replicas always come up via streaming base-backup.

Start here: pkg/reconciler/persistentvolumeclaim/storagesource.go:59 — GetCandidateStorageSourceForReplica now early-returns nil. The caller at internal/controller/cluster_create.go:1257 already treats nil as "stream from primary," so no caller-side change. GetCandidateStorageSourceForPrimary is untouched; bootstrap-from-snapshot for a new cluster still works.

Compat: clusters whose next scale-up would previously have used a VolumeSnapshot will now stream base-backup instead — slower first-replica catch-up, identical end state. Existing snapshot-restored replica PVCs are reused, not recreated, so they're unaffected.

Scope: first slice of the anti-affinity work. Subsequent slices (PVC affinity-group labels, anti-affinity-group label from the branch-operator side, storage-side placement strategy) land separately.

- GetCandidateStorageSourceForReplica now returns nil; replicas
  bootstrap via streaming base-backup.
- A VolumeSnapshot is confined to its parent's storage node, so
  snapshot-backed replicas can't honor anti-affinity placement.
- Replace replica-source unit tests with always-nil cases.
- Delete the e2e scale-up test that asserted snapshot-backed PVCs;
  general scale-up is covered in scaling_test.go and cluster_setup_test.go.
@deverts
deverts marked this pull request as draft May 26, 2026 14:14
@tsg

tsg commented May 26, 2026

Copy link
Copy Markdown
Member

I am wondering if it would be better to add a setting to disable creating replicas from snapshots. We can default it to "on", so the end result is the same. But maybe more "fork-friendly"?

@deverts
deverts marked this pull request as ready for review May 27, 2026 09:51
@deverts
deverts requested review from exekias, simonapencea and tsg May 27, 2026 15:25
return getCandidateSourceFromClusterDefinition(cluster)
_ = backupList
log.FromContext(ctx).Trace(
"VolumeSnapshot-based replica creation is disabled; using streaming base-backup",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i assume we are thinking to potentially bring this back later? otherwise we could also remove the two function calls getCandidateSourceFromClusterDefinition and getCandidateSourceFromBackupList since they are not called anywhere else

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.

True.

Yes, we will bring this back at some point in the future. That point is pretty far away though. Let me pull this out properly, we can come back when we get to it.

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.

Removed.

deverts added 2 commits May 27, 2026 21:39
After gutting GetCandidateStorageSourceForReplica, this helper has no
production callers (its only caller was the function we just disabled).
Drop the helper and the two test describe blocks that exercised it
directly.

GetCandidateStorageSourceForPrimary still uses getCandidateSourceFromBackup
and getCandidateSourceFromClusterDefinition; those stay.
The function returned nil unconditionally and had a single production
caller whose `if storageSource \!= nil { RestoreReplicaInstance }` branch
was dead. Removing it lets us also drop:

- The BackupList fetch in joinReplicaInstance (one less API List per
  replica creation).
- The dead conditional and the storageSource log field.
- RestoreReplicaInstance itself (orphan once the dead branch is gone).

jobRoleSnapshotRecovery and the restoresnapshot manager subcommand stay
— they're still used by the primary path (CreatePrimaryJobViaRestoreSnapshot).
@deverts

deverts commented May 28, 2026

Copy link
Copy Markdown
Member Author

We have several red actions: seems like they're downstream from us being behind a major Go version.

Will merge... we should upgrade, but these changes are not directly related.

@deverts
deverts merged commit 35cec37 into main May 28, 2026
12 of 19 checks passed
@deverts
deverts deleted the xata/disable-volumesnapshot-replicas branch May 28, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants