From 9b9141ee84f115fa3190bf2407cc5e14575b7edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 17 Jul 2020 12:12:49 +0200 Subject: [PATCH] ceph: stop monitoring health on cluster deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop the go routines on cluster deletion. Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/controller.go | 21 +++++++++++++++++---- pkg/operator/ceph/cluster/monitoring.go | 7 +++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pkg/operator/ceph/cluster/controller.go b/pkg/operator/ceph/cluster/controller.go index 2b81f8a69..988294710 100644 --- a/pkg/operator/ceph/cluster/controller.go +++ b/pkg/operator/ceph/cluster/controller.go @@ -368,10 +368,23 @@ func (c *ClusterController) requestClusterDelete(cluster *cephv1.CephCluster) (r logger.Infof("delete event for cluster %q in namespace %q", cluster.Name, cluster.Namespace) - if cluster, ok := c.clusterMap[cluster.Namespace]; ok && !cluster.closedStopCh { - // close the goroutines watching the health of the cluster (mons, osds, ceph status, etc) - close(cluster.stopCh) - cluster.closedStopCh = true + if cluster, ok := c.clusterMap[cluster.Namespace]; ok { + // if not already stopped, stop clientcontroller and bucketController + if !cluster.closedStopCh { + close(cluster.stopCh) + cluster.closedStopCh = true + } + + // close the goroutines watching the health of the cluster (mons, osds, ceph status) + var isDisabled bool + for _, daemon := range monitorDaemonList { + isDisabled = isMonitoringDisabled(daemon, cluster.Spec) + if _, ok := cluster.monitoringChannels[daemon]; ok { + if !isDisabled { + close(cluster.monitoringChannels[daemon].stopChan) + } + } + } } err := c.checkIfVolumesExist(cluster) diff --git a/pkg/operator/ceph/cluster/monitoring.go b/pkg/operator/ceph/cluster/monitoring.go index 1dbe6da3a..de09c6475 100644 --- a/pkg/operator/ceph/cluster/monitoring.go +++ b/pkg/operator/ceph/cluster/monitoring.go @@ -26,11 +26,14 @@ import ( "github.com/rook/rook/pkg/operator/ceph/object/bucket" ) +var ( + monitorDaemonList = []string{"mon", "osd", "status"} +) + func (c *ClusterController) configureCephMonitoring(cluster *cluster, clusterInfo *cephclient.ClusterInfo) { var isDisabled bool - daemons := []string{"mon", "osd", "status"} - for _, daemon := range daemons { + for _, daemon := range monitorDaemonList { // Is the monitoring enabled for that daemon? isDisabled = isMonitoringDisabled(daemon, cluster.Spec) if health, ok := cluster.monitoringChannels[daemon]; ok {