Skip to content

Commit

Permalink
check restoring PV finalizer before checking cluster ID in Persisntet…
Browse files Browse the repository at this point in the history
…VolumeReconciler

`getCephClusterIDFromSCName` works correctly only for storage class
names provisioned by Rook/Ceph. However, the PVs requested to
PersistentVolumeReconciler aren't necessarily provisioned by Rook/Ceph.

This commit resolves the problem above by checking that the PV has the
correct finalizer before checking calling `getCephClusterIDFromSCName`.

Signed-off-by: Ryotaro Banno <[email protected]>
  • Loading branch information
ushitora-anqou committed Dec 5, 2024
1 parent e9f3394 commit 1b5e375
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/controller/persistentvolume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func (r *PersistentVolumeReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, fmt.Errorf("failed to get PersistentVolume: %w", err)
}

// Make sure the PV has the finalizer.
if !controllerutil.ContainsFinalizer(&pv, RestoringPVFinalizerName) {
return ctrl.Result{}, nil
}

// Check if the PV is managed by the target Ceph cluster.
clusterID, err := getCephClusterIDFromSCName(ctx, r.client, pv.Spec.StorageClassName)
if err != nil {
Expand All @@ -77,11 +82,6 @@ func (r *PersistentVolumeReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, nil
}

// Make sure the PV has the finalizer.
if !controllerutil.ContainsFinalizer(&pv, RestoringPVFinalizerName) {
return ctrl.Result{}, nil
}

// Make sure the PV has a deletionTimestamp.
if pv.GetDeletionTimestamp().IsZero() {
return ctrl.Result{}, nil
Expand Down

0 comments on commit 1b5e375

Please sign in to comment.