From 47b8bb989e1bcab1f5d661c64483ab3235c7eb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 17 Feb 2022 15:32:37 +0100 Subject: [PATCH] core: move clusterInfo discovery in converged cluster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The external code has its own mechanism to look up the clusterInfo so let's move this to the non-external condition to clarify the code. Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/cluster.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/operator/ceph/cluster/cluster.go b/pkg/operator/ceph/cluster/cluster.go index c9cf926f4..cc1d7a130 100755 --- a/pkg/operator/ceph/cluster/cluster.go +++ b/pkg/operator/ceph/cluster/cluster.go @@ -173,19 +173,6 @@ func (c *ClusterController) initializeCluster(cluster *cluster) error { } } - clusterInfo, _, _, err := mon.LoadClusterInfo(c.context, c.OpManagerCtx, cluster.Namespace) - if err != nil { - if errors.Is(err, mon.ClusterInfoNoClusterNoSecret) { - logger.Info("clusterInfo not yet found, must be a new cluster.") - } else { - return errors.Wrap(err, "failed to load cluster info") - } - } else { - clusterInfo.OwnerInfo = cluster.ownerInfo - clusterInfo.SetName(c.namespacedName.Name) - cluster.ClusterInfo = clusterInfo - } - // Depending on the cluster type choose the correct orchestation if cluster.Spec.External.Enable { err := c.configureExternalCephCluster(cluster) @@ -194,6 +181,18 @@ func (c *ClusterController) initializeCluster(cluster *cluster) error { return errors.Wrap(err, "failed to configure external ceph cluster") } } else { + clusterInfo, _, _, err := mon.LoadClusterInfo(c.context, c.OpManagerCtx, cluster.Namespace) + if err != nil { + if errors.Is(err, mon.ClusterInfoNoClusterNoSecret) { + logger.Info("clusterInfo not yet found, must be a new cluster.") + } else { + return errors.Wrap(err, "failed to load cluster info") + } + } else { + clusterInfo.OwnerInfo = cluster.ownerInfo + clusterInfo.SetName(c.namespacedName.Name) + cluster.ClusterInfo = clusterInfo + } // If the local cluster has already been configured, immediately start monitoring the cluster. // Test if the cluster has already been configured if the mgr deployment has been created. // If the mgr does not exist, the mons have never been verified to be in quorum.