From 0ab6c34bf2a1a756348a1493c5400572cacc2fd7 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 15 Feb 2023 09:45:25 +0100 Subject: [PATCH] core: set rbd default map options Set the rbd map default option to ms_mode=prefer_crc when v2 ports are used and encryption is disabled. If we dont pass/set the ms_mode in the map options the kernel client will assume its using v1 ports and map operation will fail. Signed-off-by: Madhu Rajanna --- pkg/operator/ceph/cluster/cluster.go | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkg/operator/ceph/cluster/cluster.go b/pkg/operator/ceph/cluster/cluster.go index c3a1b18b9..c31f8c78d 100755 --- a/pkg/operator/ceph/cluster/cluster.go +++ b/pkg/operator/ceph/cluster/cluster.go @@ -598,17 +598,25 @@ func (c *cluster) reportTelemetry() { func (c *cluster) configureMsgr2() error { encryptionSetting := "secure" - defaultRBDMapOptions := "ms_mode=secure" + rbdMapOptions := "rbd_default_map_options" encryptionGlobalConfigSettings := map[string]string{ - "ms_cluster_mode": encryptionSetting, - "ms_service_mode": encryptionSetting, - "ms_client_mode": encryptionSetting, - "rbd_default_map_options": defaultRBDMapOptions, + "ms_cluster_mode": encryptionSetting, + "ms_service_mode": encryptionSetting, + "ms_client_mode": encryptionSetting, + rbdMapOptions: "ms_mode=secure", } monStore := config.GetMonStore(c.context, c.ClusterInfo) - // If the user has disabled encryption, remove the encryption settings - if c.Spec.Network.Connections == nil || c.Spec.Network.Connections.Encryption == nil || !c.Spec.Network.Connections.Encryption.Enabled { + encryptionEnabled := c.Spec.Network.Connections != nil && + c.Spec.Network.Connections.Encryption != nil && + c.Spec.Network.Connections.Encryption.Enabled + + if encryptionEnabled { + logger.Infof("setting msgr2 encryption mode to %q", encryptionSetting) + if err := monStore.SetAll("global", encryptionGlobalConfigSettings); err != nil { + return err + } + } else { encryptionConfig := []config.Option{} for k := range encryptionGlobalConfigSettings { encryptionConfig = append(encryptionConfig, config.Option{Who: "global", Option: k}) @@ -616,13 +624,15 @@ func (c *cluster) configureMsgr2() error { if err := monStore.DeleteAll(encryptionConfig...); err != nil { return errors.Wrap(err, "failed to delete msgr2 encryption settings") } - } else { - logger.Infof("setting msgr2 encryption mode to %q", encryptionSetting) - if err := monStore.SetAll("global", encryptionGlobalConfigSettings); err != nil { - return err + + // set default rbd map options to enable msgr2 in the kernel if it's + // required even with encryption disabled + if c.Spec.Network.Connections != nil && c.Spec.Network.Connections.RequireMsgr2 { + if err := monStore.SetAll("global", map[string]string{rbdMapOptions: "ms_mode=prefer-crc"}); err != nil { + return err + } } } - // Set network compression if c.ClusterInfo.CephVersion.IsAtLeastQuincy() { if c.Spec.Network.Connections == nil || c.Spec.Network.Connections.Compression == nil || !c.Spec.Network.Connections.Compression.Enabled {