Skip to content

Commit

Permalink
EVEREST-1820 | fix DBR controller watch source config (#637)
Browse files Browse the repository at this point in the history
Signed-off-by: Mayank Shah <[email protected]>
  • Loading branch information
mayankshah1607 authored Jan 14, 2025
1 parent b38e7d1 commit 34157ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/controller/databasecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func (r *DatabaseClusterReconciler) ReconcileWatchers(ctx context.Context) error
log := log.FromContext(ctx)
addWatcher := func(dbEngineType everestv1alpha1.EngineType, obj client.Object) error {
sources := []source.Source{
source.TypedKind(r.Cache, obj, &handler.EnqueueRequestForObject{}),
source.Kind(r.Cache, obj, &handler.EnqueueRequestForObject{}),
}

// special case for PXC - we need to watch pxc-restore to be sure the db is reconciled on every pxc-restore status update.
Expand Down
13 changes: 12 additions & 1 deletion internal/controller/databaseclusterrestore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,18 @@ func (r *DatabaseClusterRestoreReconciler) ReconcileWatchers(ctx context.Context

log := log.FromContext(ctx)
addWatcher := func(dbEngineType everestv1alpha1.EngineType, obj client.Object) error {
src := source.TypedKind(r.Cache, obj, handler.EnqueueRequestForOwner(r.Scheme, r.RESTMapper(), &everestv1alpha1.DatabaseCluster{}))
// This source is the same as calling Owns() on the controller builder.
// I.e, &DatabaseClusterRestore{} owns obj.
src := source.Kind(
r.Cache,
obj,
handler.EnqueueRequestForOwner(
r.Scheme,
r.RESTMapper(),
&everestv1alpha1.DatabaseClusterRestore{},
handler.OnlyControllerOwner(),
),
)
if err := r.controller.addWatchers(string(dbEngineType), src); err != nil {
return err
}
Expand Down

0 comments on commit 34157ea

Please sign in to comment.