From b780e5b5c052bac61d8b6498c4e68c1d103d202e Mon Sep 17 00:00:00 2001 From: Santosh Pillai Date: Tue, 2 Feb 2021 21:49:07 +0530 Subject: [PATCH] ceph: skip pdb reconcile on create and delete events This PR makes create and delete events on pdb a no-op. Update event only triggers reconcile if its the main OSD pdb and allowed disruptions is 0. This prevents controller to reconcile on pdb events namespaces outside rook ceph. Signed-off-by: Santosh Pillai --- .../ceph/disruption/clusterdisruption/add.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/disruption/clusterdisruption/add.go b/pkg/operator/ceph/disruption/clusterdisruption/add.go index 4ed7a2c09..ad9d2a7e7 100644 --- a/pkg/operator/ceph/disruption/clusterdisruption/add.go +++ b/pkg/operator/ceph/disruption/clusterdisruption/add.go @@ -47,7 +47,7 @@ func Add(mgr manager.Manager, context *controllerconfig.Context) error { return errors.Wrap(err, "failed to add ceph scheme to manager scheme") } - // this will be used to associate namespaces and cephclusters. + // This will be used to associate namespaces and cephclusters. sharedClusterMap := &ClusterMap{} reconcileClusterDisruption := &ReconcileClusterDisruption{ @@ -87,15 +87,24 @@ func Add(mgr manager.Manager, context *controllerconfig.Context) error { return err } + // Only reconcile for PDB update event when allowed disruptions for the main OSD PDB is 0. + // This means that one of the OSD is down due to node drain or any other reason pdbPredicate := predicate.Funcs{ + CreateFunc: func(e event.CreateEvent) bool { + // Do not reconcile when PDB is created + return false + }, UpdateFunc: func(e event.UpdateEvent) bool { pdb, ok := e.ObjectNew.DeepCopyObject().(*policyv1beta1.PodDisruptionBudget) if !ok { return false } - // only reconcile if allowed disruptions is 0 in the main PDB return pdb.Name == osdPDBAppName && pdb.Status.DisruptionsAllowed == 0 }, + DeleteFunc: func(e event.DeleteEvent) bool { + // Do not reconcile when PDB is deleted + return false + }, } // Watch for main PodDisruptionBudget and enqueue the CephCluster in the namespace @@ -104,7 +113,7 @@ func Add(mgr manager.Manager, context *controllerconfig.Context) error { handler.EnqueueRequestsFromMapFunc(handler.MapFunc(func(obj client.Object) []reconcile.Request { pdb, ok := obj.(*policyv1beta1.PodDisruptionBudget) if !ok { - // not a pdb, returning empty + // Not a pdb, returning empty logger.Errorf("PDB handler received non-PDB") return []reconcile.Request{} }