Additional volume migration tests and realignment triggering#336
Open
noctarius wants to merge 5 commits into
Open
Additional volume migration tests and realignment triggering#336noctarius wants to merge 5 commits into
noctarius wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands volume-migration validation and introduces an operator-driven “data realignment” trigger path so the control plane can periodically (or explicitly) re-align cluster state after volume moves.
Changes:
- Extend
fio_migration_test.pyto optionally create KubernetesVolumeSnapshots pre-migration and verify snapshots still resolve viasbctlpost-migration. - Add a WebAPI client method and controller logic to trigger control-plane data realignment based on a persisted “pending” flag, periodic interval, or an explicit annotation trigger (with accompanying tests and CRD/API updates).
- Enhance the cleanup script with configurable Helm release / CSI driver targeting and additional PV cleanup logic.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| operator/test/fio_migration_test.py | Adds optional pre-migration snapshot creation + sbctl-based snapshot verification and cleanup. |
| operator/internal/webapi/rebalancing.go | Changes migration-create retry behavior to defer creation after cancelling an existing migration. |
| operator/internal/webapi/realignment.go | Adds WebAPI call to trigger control-plane data realignment. |
| operator/internal/webapi/realignment_test.go | Adds unit tests for the realignment WebAPI call. |
| operator/internal/controller/volumerebalancer_controller.go | Adds periodic/forced realignment logic, new requeue calculation, and annotation-trigger handling. |
| operator/internal/controller/volumerebalancer_realignment_test.go | Adds decision-table and reconciler behavior tests for realignment. |
| operator/internal/controller/volumemigration_controller.go | Flags the owning StorageCluster as “pending realignment” after successful migrations; handles deferred CreateMigration. |
| operator/internal/controller/volumemigration_realignment_test.go | Adds tests for pending-realignment flagging behavior. |
| operator/config/crd/bases/storage.simplyblock.io_storageclusters.yaml | Extends CRD schema with spec dataRealignment and status fields for pending/last realignment. |
| operator/api/v1alpha1/storagecluster_types.go | Adds API types/fields for data realignment settings and status tracking. |
| operator/api/v1alpha1/zz_generated.deepcopy.go | Updates generated deep-copies for the new API fields/types. |
| helm-charts/scripts/cleanup-simplyblock.sh | Adds CLI options for Helm release/CSI driver and extra PV cleanup behavior. |
Files not reviewed (1)
- operator/api/v1alpha1/zz_generated.deepcopy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1768
to
+1772
| p.add_argument("--snapshot-chance", type=float, default=SNAPSHOT_CHANCE, | ||
| help="probability (0..1) of taking a VolumeSnapshot of a volume just " | ||
| "before migrating it, so the migration must carry the snapshot; the " | ||
| "snapshot id is validated via sbctl after creation and after the " | ||
| f"migration (default {SNAPSHOT_CHANCE}; 0 disables snapshots)") |
Comment on lines
+29
to
+31
| if !strings.Contains(gotPath, clusterUUID) { | ||
| t.Errorf("path %q does not contain cluster UUID %q", gotPath, clusterUUID) | ||
| } |
Comment on lines
+331
to
+343
| func assertEvent(t *testing.T, rec *record.FakeRecorder, reason string) { | ||
| t.Helper() | ||
| for { | ||
| select { | ||
| case e := <-rec.Events: | ||
| if strings.Contains(e, reason) { | ||
| return | ||
| } | ||
| default: | ||
| t.Fatalf("expected event containing %q", reason) | ||
| } | ||
| } | ||
| } |
| } | ||
|
|
||
| // +kubebuilder:rbac:groups=storage.simplyblock.io,resources=storageclusters,verbs=get;list;watch | ||
| // +kubebuilder:rbac:groups=storage.simplyblock.io,resources=storageclusters,verbs=get;list;watch;update;patch |
Comment on lines
+20
to
+32
| -h, --help Show this help message | ||
| EOF | ||
| exit 0 | ||
| } | ||
|
|
||
| # Abort with usage if an option that takes a value was given none. | ||
| # $1 = option name (for the message), $2 = the value passed (may be empty). | ||
| require_value() { | ||
| if [[ -z "$2" ]]; then | ||
| echo "Option $1 requires a value" >&2 | ||
| usage | ||
| fi | ||
| } |
Comment on lines
+66
to
70
| -*) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| ;; | ||
| *) |
Comment on lines
+53
to
+65
| --helm-release=*) | ||
| HELM_RELEASE_ARG="${1#*=}" | ||
| shift | ||
| ;; | ||
| --csi-driver) | ||
| require_value "$1" "${2:-}" | ||
| CSI_DRIVER_ARG="$2" | ||
| shift 2 | ||
| ;; | ||
| --csi-driver=*) | ||
| CSI_DRIVER_ARG="${1#*=}" | ||
| shift | ||
| ;; |
noctarius
force-pushed
the
additional-volume-migration-tests
branch
from
July 17, 2026 10:26
f7466ff to
b71fe2b
Compare
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.
This PR adds snapshot tests and a way to automatically trigger realignment at a certain time interval or if the a node drain finished.