Skip to content

Additional volume migration tests and realignment triggering#336

Open
noctarius wants to merge 5 commits into
mainfrom
additional-volume-migration-tests
Open

Additional volume migration tests and realignment triggering#336
noctarius wants to merge 5 commits into
mainfrom
additional-volume-migration-tests

Conversation

@noctarius

Copy link
Copy Markdown
Collaborator

This PR adds snapshot tests and a way to automatically trigger realignment at a certain time interval or if the a node drain finished.

@noctarius noctarius added this to the 26.3 milestone Jul 16, 2026
@noctarius noctarius self-assigned this Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.py to optionally create Kubernetes VolumeSnapshots pre-migration and verify snapshots still resolve via sbctl post-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
noctarius force-pushed the additional-volume-migration-tests branch from f7466ff to b71fe2b Compare July 17, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants