Skip to content

Commit

Permalink
Watch for StorageProfile updates to reconcile DVs (#3562)
Browse files Browse the repository at this point in the history
Currently, completing an incomplete StorageProfile does not reconcile
the relevant incomplete DVs waiting fro it, unlike the case of missing
StorageClass.

Even after updating the StorageProfile claimPropertySets to have
relevant AccessMode and VolumeMode, the DV is stuck with incomplete
AccessMode and VolumeMode until its exponential back-off reconcile, or
until it's manually updated (e.g. annotated) and reconciled.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Co-authored-by: Arnon Gilboa <agilboa@redhat.com>
  • Loading branch information
kubevirt-bot and arnongilboa authored Dec 12, 2024
1 parent 9a4d3cf commit 1ca24be
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions pkg/controller/datavolume/controller-base.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,28 @@ func addDataVolumeControllerCommonWatches(mgr manager.Manager, dataVolumeControl
}
}

// Watch for SC updates and reconcile the DVs waiting for default SC
// Relevant only when the DV StorageSpec has no AccessModes set and no matching StorageClass yet, so PVC cannot be created (test_id:9922)
if err := dataVolumeController.Watch(source.Kind(mgr.GetCache(), &storagev1.StorageClass{}, handler.TypedEnqueueRequestsFromMapFunc[*storagev1.StorageClass](
func(ctx context.Context, obj *storagev1.StorageClass) []reconcile.Request {
dvList := &cdiv1.DataVolumeList{}
if err := mgr.GetClient().List(ctx, dvList, client.MatchingFields{dvPhaseField: ""}); err != nil {
return nil
}
var reqs []reconcile.Request
for _, dv := range dvList.Items {
if getDataVolumeOp(ctx, mgr.GetLogger(), &dv, mgr.GetClient()) == op {
reqs = append(reqs, reconcile.Request{NamespacedName: types.NamespacedName{Name: dv.Name, Namespace: dv.Namespace}})
// Watch for StorageClass and StorageProfile updates and reconcile the DVs waiting for StorageClass or its complete StorageProfile.
// Relevant only when the DV StorageSpec has no AccessModes set and no matching StorageClass with compelete StorageProfile yet,
// so PVC cannot be created (test_id:9922).
for _, k := range []client.Object{&storagev1.StorageClass{}, &cdiv1.StorageProfile{}} {
if err := dataVolumeController.Watch(source.Kind(mgr.GetCache(), k, handler.EnqueueRequestsFromMapFunc(
func(ctx context.Context, obj client.Object) []reconcile.Request {
dvList := &cdiv1.DataVolumeList{}
if err := mgr.GetClient().List(ctx, dvList, client.MatchingFields{dvPhaseField: ""}); err != nil {
return nil
}
}
return reqs
},
),
)); err != nil {
return err
var reqs []reconcile.Request
for _, dv := range dvList.Items {
if getDataVolumeOp(ctx, mgr.GetLogger(), &dv, mgr.GetClient()) == op {
reqs = append(reqs, reconcile.Request{NamespacedName: types.NamespacedName{Name: dv.Name, Namespace: dv.Namespace}})
}
}
return reqs
},
),
)); err != nil {
return err
}
}

// Watch for PV updates to reconcile the DVs waiting for available PV
Expand Down

0 comments on commit 1ca24be

Please sign in to comment.