From d237dff985edfe4f9209eca617584ae7b42880bd Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 18 Jul 2023 20:50:52 +0530 Subject: [PATCH] external: set RequireMsgr2 if v2 port is configured Currently if we use the msgr2 port, cs-cluster-config-json looks like "monitors":["192.59.109.11:3300","192.59.109.13:6789","192.59.109.12:6789"] The first monitor is passed by python script and rest are Discovered by rook operator, so if the first mon is using the v2 port lets update the other mons also by setting up the RequireMsgr2 flag Signed-off-by: parth-gr (cherry picked from commit 2c4897f88c41acace9465e54ff8251c044b43e27) --- pkg/operator/ceph/cluster/cluster_external.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/operator/ceph/cluster/cluster_external.go b/pkg/operator/ceph/cluster/cluster_external.go index fbc1c2141..1153140f1 100644 --- a/pkg/operator/ceph/cluster/cluster_external.go +++ b/pkg/operator/ceph/cluster/cluster_external.go @@ -24,6 +24,7 @@ import ( cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/daemon/ceph/client" + "github.com/rook/rook/pkg/daemon/ceph/util" "github.com/rook/rook/pkg/operator/ceph/cluster/mgr" "github.com/rook/rook/pkg/operator/ceph/cluster/mon" "github.com/rook/rook/pkg/operator/ceph/cluster/nodedaemon" @@ -112,6 +113,20 @@ func (c *ClusterController) configureExternalCephCluster(cluster *cluster) error return errors.Wrap(err, "failed to create csi config map") } + // update the msgr2 flag + for _, m := range cluster.ClusterInfo.Monitors { + // m.Endpoint=10.1.115.104:3300 + monPort := util.GetPortFromEndpoint(m.Endpoint) + if monPort == client.Msgr2port { + if cluster.Spec.Network.Connections == nil { + cluster.Spec.Network.Connections = &cephv1.ConnectionsSpec{} + } + cluster.Spec.Network.Connections.RequireMsgr2 = true + logger.Debugf("a v2 port was found for a mon endpoint, so msgr2 is required") + break + } + } + // Save CSI configmap monEndpoints := csi.MonEndpoints(cluster.ClusterInfo.Monitors, cluster.Spec.RequireMsgr2()) err = csi.SaveClusterConfig(c.context.Clientset, c.namespacedName.Namespace, cluster.ClusterInfo, &csi.CsiClusterConfigEntry{Namespace: cluster.ClusterInfo.Namespace, Monitors: monEndpoints})