Skip to content

Commit

Permalink
VolumeReplicationGroupReconciler must watch VolumeGroupReolication re…
Browse files Browse the repository at this point in the history
…sources

Signed-off-by: Elena Gershkovich <elenage@il.ibm.com>
  • Loading branch information
ELENAGER committed Sep 19, 2024
1 parent 2855e1e commit ffb9e5a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/controller/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type VolumeReplicationGroupReconciler struct {
}

// SetupWithManager sets up the controller with the Manager.
//
// nolint: funlen
func (r *VolumeReplicationGroupReconciler) SetupWithManager(
mgr ctrl.Manager, ramenConfig *ramendrv1alpha1.RamenConfig,
) error {
Expand Down Expand Up @@ -97,6 +99,10 @@ func (r *VolumeReplicationGroupReconciler) SetupWithManager(
handler.EnqueueRequestsFromMapFunc(r.VRMapFunc),
builder.WithPredicates(rmnutil.CreateOrDeleteOrResourceVersionUpdatePredicate{}),
).
Watches(&volrep.VolumeGroupReplication{},
handler.EnqueueRequestsFromMapFunc(r.VGRMapFunc),
builder.WithPredicates(rmnutil.CreateOrDeleteOrResourceVersionUpdatePredicate{}),
).
Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(r.configMapFun)).
Owns(&volrep.VolumeReplication{}).
Owns(&volrep.VolumeGroupReplication{})
Expand Down Expand Up @@ -1558,6 +1564,20 @@ func filterVRGDependentObjects(reader client.Reader, obj client.Object, log logr
return req
}

func (r *VolumeReplicationGroupReconciler) VGRMapFunc(ctx context.Context, obj client.Object) []reconcile.Request {
log := ctrl.Log.WithName("vgrmap").WithName("VolumeReplicationGroup")

vgr, ok := obj.(*volrep.VolumeGroupReplication)
if !ok {
log.Info("map function received non-vgr resource")

return []reconcile.Request{}
}

return filterVRGDependentObjects(r.Client, obj,
log.WithValues("vgr", types.NamespacedName{Name: vgr.Name, Namespace: vgr.Namespace}))
}

func (r *VolumeReplicationGroupReconciler) VRMapFunc(ctx context.Context, obj client.Object) []reconcile.Request {
log := ctrl.Log.WithName("vrmap").WithName("VolumeReplicationGroup")

Expand Down

0 comments on commit ffb9e5a

Please sign in to comment.