From 8db14885b5b79ead00caf171ded1faad66236ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 25 Mar 2020 16:32:01 +0100 Subject: [PATCH] ceph: controller fix misleading debug log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They are cases where we let the exponential backoff retry and some where we force our own retry. Let's properly log this information. Signed-off-by: Sébastien Han --- pkg/operator/ceph/controller/controller_utils.go | 16 ++++++++-------- pkg/operator/ceph/file/controller.go | 4 +--- pkg/operator/ceph/nfs/controller.go | 4 +--- pkg/operator/ceph/object/controller.go | 3 +-- pkg/operator/ceph/object/user/controller.go | 4 +--- pkg/operator/ceph/pool/controller.go | 4 +--- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/pkg/operator/ceph/controller/controller_utils.go b/pkg/operator/ceph/controller/controller_utils.go index 24e10d849..35c7aa5a5 100644 --- a/pkg/operator/ceph/controller/controller_utils.go +++ b/pkg/operator/ceph/controller/controller_utils.go @@ -43,7 +43,7 @@ var ( ) // IsReadyToReconcile determines if a controller is ready to reconcile or not -func IsReadyToReconcile(client client.Client, clustercontext *clusterd.Context, namespacedName types.NamespacedName) (cephv1.ClusterSpec, bool, bool, reconcile.Result) { +func IsReadyToReconcile(client client.Client, clustercontext *clusterd.Context, namespacedName types.NamespacedName, controllerName string) (cephv1.ClusterSpec, bool, bool, reconcile.Result) { namespacedName.Name = namespacedName.Namespace cephClusterExists := true @@ -54,15 +54,15 @@ func IsReadyToReconcile(client client.Client, clustercontext *clusterd.Context, if err != nil { if kerrors.IsNotFound(err) { cephClusterExists = false - logger.Errorf("CephCluster resource %q not found in namespace %q", namespacedName.Name, namespacedName.Namespace) + logger.Errorf("%q: CephCluster resource %q not found in namespace %q", controllerName, namespacedName.Name, namespacedName.Namespace) return cephv1.ClusterSpec{}, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady } else if err != nil { - logger.Errorf("failed to fetch CephCluster %v", err) + logger.Errorf("%q:failed to fetch CephCluster %v", controllerName, err) return cephv1.ClusterSpec{}, false, cephClusterExists, ImmediateRetryResult } } - logger.Debugf("CephCluster resource %q found in namespace %q", namespacedName.Name, namespacedName.Namespace) + logger.Debugf("%q: CephCluster resource %q found in namespace %q", controllerName, namespacedName.Name, namespacedName.Namespace) // If the cluster is healthy // Test a Ceph command to verify the Operator is ready @@ -70,20 +70,20 @@ func IsReadyToReconcile(client client.Client, clustercontext *clusterd.Context, status, err := cephclient.Status(clustercontext, namespacedName.Namespace) if err != nil { if strings.Contains(err.Error(), "error calling conf_read_file") { - logger.Info("operator is not ready to run ceph command, cannot reconcile yet.") + logger.Infof("%q: operator is not ready to run ceph command, cannot reconcile yet.", controllerName) return cephCluster.Spec, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady } // We should not arrive there - logger.Errorf("ceph command error %v", err) + logger.Errorf("%q: ceph command error %v", controllerName, err) return cephCluster.Spec, false, cephClusterExists, ImmediateRetryResult } // If Ceph status is ok we can reconcile if status.Health.Status == "HEALTH_OK" || status.Health.Status == "HEALTH_WARN" { - logger.Debugf("ceph status is %q, operator is ready to run ceph command, reconciling", status.Health.Status) + logger.Debugf("%q: ceph status is %q, operator is ready to run ceph command, reconciling", controllerName, status.Health.Status) return cephCluster.Spec, true, cephClusterExists, reconcile.Result{} } - logger.Debugf("CephCluster resource %q found in namespace %q but cluster state is not appropriate %q", namespacedName.Name, namespacedName.Namespace, status.Health.Status) + logger.Debugf("%q: CephCluster resource %q found in namespace %q but cluster state is not appropriate %q", controllerName, namespacedName.Name, namespacedName.Namespace, status.Health.Status) return cephCluster.Spec, false, cephClusterExists, WaitForRequeueIfCephClusterNotReady } diff --git a/pkg/operator/ceph/file/controller.go b/pkg/operator/ceph/file/controller.go index 4c6264c61..3e76dfd42 100644 --- a/pkg/operator/ceph/file/controller.go +++ b/pkg/operator/ceph/file/controller.go @@ -159,7 +159,7 @@ func (r *ReconcileCephFilesystem) reconcile(request reconcile.Request) (reconcil } // Make sure a CephCluster is present otherwise do nothing - cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName) + cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName) if !isReadyToReconcile { // This handles the case where the Ceph Cluster is gone and we want to delete that CR // We skip the deleteFilesystem() function since everything is gone already @@ -177,8 +177,6 @@ func (r *ReconcileCephFilesystem) reconcile(request reconcile.Request) (reconcil // Return and do not requeue. Successful deletion. return reconcile.Result{}, nil } - - logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String()) return reconcileResponse, nil } r.cephClusterSpec = &cephClusterSpec diff --git a/pkg/operator/ceph/nfs/controller.go b/pkg/operator/ceph/nfs/controller.go index 7f6284e4d..0843ab780 100644 --- a/pkg/operator/ceph/nfs/controller.go +++ b/pkg/operator/ceph/nfs/controller.go @@ -158,7 +158,7 @@ func (r *ReconcileCephNFS) reconcile(request reconcile.Request) (reconcile.Resul } // Make sure a CephCluster is present otherwise do nothing - cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName) + cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName) if !isReadyToReconcile { // This handles the case where the Ceph Cluster is gone and we want to delete that CR // We skip the deleteStore() function since everything is gone already @@ -176,8 +176,6 @@ func (r *ReconcileCephNFS) reconcile(request reconcile.Request) (reconcile.Resul // Return and do not requeue. Successful deletion. return reconcile.Result{}, nil } - - logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String()) return reconcileResponse, nil } r.cephClusterSpec = &cephClusterSpec diff --git a/pkg/operator/ceph/object/controller.go b/pkg/operator/ceph/object/controller.go index 035b46554..8617f51a0 100644 --- a/pkg/operator/ceph/object/controller.go +++ b/pkg/operator/ceph/object/controller.go @@ -159,7 +159,7 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci } // Make sure a CephCluster is present otherwise do nothing - cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName) + cephClusterSpec, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName) if !isReadyToReconcile { // This handles the case where the Ceph Cluster is gone and we want to delete that CR // We skip the deleteStore() function since everything is gone already @@ -178,7 +178,6 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci return reconcile.Result{}, nil } - logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String()) return reconcileResponse, nil } r.cephClusterSpec = &cephClusterSpec diff --git a/pkg/operator/ceph/object/user/controller.go b/pkg/operator/ceph/object/user/controller.go index 68a0d65aa..82d9134d2 100644 --- a/pkg/operator/ceph/object/user/controller.go +++ b/pkg/operator/ceph/object/user/controller.go @@ -151,7 +151,7 @@ func (r *ReconcileObjectStoreUser) reconcile(request reconcile.Request) (reconci } // Make sure a CephCluster is present otherwise do nothing - _, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName) + _, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName) if !isReadyToReconcile { // This handles the case where the Ceph Cluster is gone and we want to delete that CR // We skip the deleteUser() function since everything is gone already @@ -169,8 +169,6 @@ func (r *ReconcileObjectStoreUser) reconcile(request reconcile.Request) (reconci // Return and do not requeue. Successful deletion. return reconcile.Result{}, nil } - - logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String()) return reconcileResponse, nil } diff --git a/pkg/operator/ceph/pool/controller.go b/pkg/operator/ceph/pool/controller.go index 0d873a377..8d29b526b 100644 --- a/pkg/operator/ceph/pool/controller.go +++ b/pkg/operator/ceph/pool/controller.go @@ -141,7 +141,7 @@ func (r *ReconcileCephBlockPool) reconcile(request reconcile.Request) (reconcile } // Make sure a CephCluster is present otherwise do nothing - _, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName) + _, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.client, r.context, request.NamespacedName, controllerName) if !isReadyToReconcile { // This handles the case where the Ceph Cluster is gone and we want to delete that CR // We skip the deletePool() function since everything is gone already @@ -159,8 +159,6 @@ func (r *ReconcileCephBlockPool) reconcile(request reconcile.Request) (reconcile // Return and do not requeue. Successful deletion. return reconcile.Result{}, nil } - - logger.Debugf("CephCluster resource not ready in namespace %q, retrying in %q.", request.NamespacedName.Namespace, opcontroller.WaitForRequeueIfCephClusterNotReadyAfter.String()) return reconcileResponse, nil }