From ff1ab64d8d00b10455983b22d2fce7e8f3da2b30 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 8 Apr 2020 18:10:05 -0600 Subject: [PATCH] ceph: skip reconcile events where the spec not updated The controllers should ignore events for status updates. The reconcile only needs to happen when the spec is updated or the resource is marked for deletion. Otherwise, the controllers may stay in an update loop as the reconcile events are triggered again every time there is a status update during the reconcile. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/controller/predicate.go | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/operator/ceph/controller/predicate.go b/pkg/operator/ceph/controller/predicate.go index 12bc05b91..bb2c73afc 100644 --- a/pkg/operator/ceph/controller/predicate.go +++ b/pkg/operator/ceph/controller/predicate.go @@ -60,14 +60,14 @@ func WatchControllerPredicate() predicate.Funcs { objNew := e.ObjectNew.(*cephv1.CephObjectStore) logger.Debug("update event from the parent object CephObjectStore") diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer) - if diff != "" || - objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() || - objOld.GetGeneration() != objNew.GetGeneration() { + if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() { // Checking if diff is not empty so we don't print it when the CR gets deleted if diff != "" { logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff) } return true + } else if objOld.GetGeneration() != objNew.GetGeneration() { + logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name) } // Handling upgrades isUpgrade := isUpgrade(objOld.GetLabels(), objNew.GetLabels()) @@ -79,42 +79,42 @@ func WatchControllerPredicate() predicate.Funcs { objNew := e.ObjectNew.(*cephv1.CephObjectStoreUser) logger.Debug("update event from the parent object CephObjectStoreUser") diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer) - if diff != "" || - objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() || - objOld.GetGeneration() != objNew.GetGeneration() { + if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() { // Checking if diff is not empty so we don't print it when the CR gets deleted if diff != "" { logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff) } return true + } else if objOld.GetGeneration() != objNew.GetGeneration() { + logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name) } case *cephv1.CephBlockPool: objNew := e.ObjectNew.(*cephv1.CephBlockPool) logger.Debug("update event from the parent object CephBlockPool") diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer) - if diff != "" || - objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() || - objOld.GetGeneration() != objNew.GetGeneration() { + if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() { // Checking if diff is not empty so we don't print it when the CR gets deleted if diff != "" { logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff) } return true + } else if objOld.GetGeneration() != objNew.GetGeneration() { + logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name) } case *cephv1.CephFilesystem: objNew := e.ObjectNew.(*cephv1.CephFilesystem) logger.Debug("update event from the parent object CephFilesystem") diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer) - if diff != "" || - objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() || - objOld.GetGeneration() != objNew.GetGeneration() { + if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() { // Checking if diff is not empty so we don't print it when the CR gets deleted if diff != "" { logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff) } return true + } else if objOld.GetGeneration() != objNew.GetGeneration() { + logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name) } // Handling upgrades isUpgrade := isUpgrade(objOld.GetLabels(), objNew.GetLabels()) @@ -126,14 +126,14 @@ func WatchControllerPredicate() predicate.Funcs { objNew := e.ObjectNew.(*cephv1.CephNFS) logger.Debug("update event from the parent object CephNFS") diff := cmp.Diff(objOld.Spec, objNew.Spec, resourceQtyComparer) - if diff != "" || - objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() || - objOld.GetGeneration() != objNew.GetGeneration() { + if diff != "" || objOld.GetDeletionTimestamp() != objNew.GetDeletionTimestamp() { // Checking if diff is not empty so we don't print it when the CR gets deleted if diff != "" { logger.Infof("CR has changed for %q. diff=%s", objNew.Name, diff) } return true + } else if objOld.GetGeneration() != objNew.GetGeneration() { + logger.Debugf("skipping resource %q update with unchanged spec", objNew.Name) } // Handling upgrades isUpgrade := isUpgrade(objOld.GetLabels(), objNew.GetLabels())