feat(operator): implement ReplicationPolicy, PVCAnnotationWatcher, ReplicationPair, and ReplicationOps controllers - #443
Open
geoffrey1330 wants to merge 33 commits into
Open
feat(operator): implement ReplicationPolicy, PVCAnnotationWatcher, ReplicationPair, and ReplicationOps controllers#443geoffrey1330 wants to merge 33 commits into
geoffrey1330 wants to merge 33 commits into
Conversation
…ation (ReplicationPolicy, ReplicationPair, ReplicationOps CRs)
…ler, superseded by ReplicationPolicy/ReplicationPair/ReplicationOps design
…plicationPair, and ReplicationOps controllers
…s, drop unused params and consts
…tcher, ReplicationPair, and ReplicationOps controllers
…hes in ReplicationPolicy controller
… helper arguments
… unparam arguments
…PR#1257 REST refactor
…est 19 for two-cluster replication
… API paths with /api/v2/clusters/{uuid}
…ting attach behavior
…icy/Slot, rename Retention to SnapshotRetention, update tests and design doc
…ReplicationPolicy test helpers
…rs it with the cluster
…lock.io_snapshotreplications.yaml
…BackendTargetID for scope=target
…tests for failover cluster UUID resolution
…not just HTTP status
…s all policies; add ReplicationOpsValidator webhook
…tus subresource and pairRef field index
…red by ReplicationPair controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes: issue-442
Adds policy-driven snapshot replication to the operator. The old
SnapshotReplicationCR is gone (removed in the previous commit) — this replaces it with a three-tier CRD hierarchy:ReplicationPair,ReplicationPolicy,ReplicationSlot, andReplicationOps.New CRDs
ReplicationPairrelpairReplicationTarget. Multiple policies may share one pair.ReplicationPolicyreplspec.pairRef. Creates and owns the backendReplicationPolicy.ReplicationSlotrelslotPVCAnnotationWatcher. Drives all backend calls and tracks the live source↔target state machine.ReplicationOpsreplopsStorageClusterOps).Annotation mechanism
Opt PVCs into replication via
storage.simplyblock.io/replication-policyon a StorageClass (applies to all PVCs) or directly on a PVC (overrides the StorageClass). Post-bind annotation changes are fully handled: a policy change detaches the old slot and attaches a new one; removing the annotation detaches and cleans up snapshots on both sides.Controllers
ReplicationPairreconciler — check-or-create the backendReplicationTargetfor the source/target cluster pair; stores the UUID instatus.backendTargetID; guards deletion until noReplicationPolicyCRs reference it.ReplicationPolicyreconciler — waits for the referencedReplicationPairto be ready, then check-or-create the backendReplicationPolicyusing the pair'sbackendTargetID; counts owned slots instatus.slotCount; guards deletion until all slots are gone; on deletion removes only the backend policy (the backend target is owned by the pair).PVCAnnotationWatcher— watches PVCs and StorageClasses for annotation changes; creates, replaces, or deletesReplicationSlotCRs; waits for the PVC to beBoundbefore creating a slot.ReplicationSlotreconciler — drives the per-volume state machine (attaching → poll_attach → replicating → cutover_pending / cutover_done / failed_over → detaching → deleted); syncslastReplicatedAtfrom the backend; finalizer ensures detach completes before the CR is GC'd.ReplicationOpsreconciler — one-active-per-policy guard viaReplicationPolicy.status.activeOpsRef; failover and failback forscope=policyandscope=volume.Test plan
kubectl get relpair,repl,relslot,replopsworkReplicationPairpointing at source and target clusters; verifystatus.ready=trueandstatus.backendTargetIDpopulatedReplicationPolicyreferencing the pair; verifystatus.ready=trueandstatus.backendPolicyIDpopulatedstorage.simplyblock.io/replication-policy; provision a PVC; verify aReplicationSlotis created and reachesstatus.state=replicatingdetachingand new slot is created once the old one is GC'ddetaching, backendDELETEis called, and slot CR is removedReplicationOps{action: failover, scope: policy}; verify all slots move tofailed_overandstatus.phase=SucceededReplicationOpsfor the same policy while the first isRunning; verify it staysPending(activeOpsRefguard)ReplicationOps{action: failback}; verifyreplication_failback+replication_commitcalled per volume and slots return todirection=sourceReplicationPolicy; verify blocked while slots exist, then GC'd cleanly without deleting the backend targetReplicationPair; verify blocked while policies reference it, then GC'd and backend target deletedTest Result
ReplicationPair
ReplicationPolicy
ReplicationSlot