From 8593a5398dc1118a5494d1363fce4ff8b80c3d32 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 18 Jan 2023 10:02:20 +0100 Subject: [PATCH] core: unset messenger2 configuration Unset encryption configuration and default rbd map option when the encryption is not enabled or it disabled after sometime. Unset compression option also when the compression is disabled. Signed-off-by: Madhu Rajanna (cherry picked from commit d1a86f6a63338907e930cf3ac934cfa0049110c7) --- pkg/operator/ceph/cluster/cluster.go | 59 ++++++++++++----------- pkg/operator/ceph/cluster/cluster_test.go | 3 ++ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/pkg/operator/ceph/cluster/cluster.go b/pkg/operator/ceph/cluster/cluster.go index 416d9d81d..61c7dca82 100755 --- a/pkg/operator/ceph/cluster/cluster.go +++ b/pkg/operator/ceph/cluster/cluster.go @@ -596,51 +596,54 @@ func (c *cluster) reportTelemetry() { } func (c *cluster) configureMsgr2() error { - if c.Spec.Network.Connections == nil { - return nil + encryptionSetting := "secure" + defaultRBDMapOptions := "ms_mode=secure" + encryptionGlobalConfigSettings := map[string]string{ + "ms_cluster_mode": encryptionSetting, + "ms_service_mode": encryptionSetting, + "ms_client_mode": encryptionSetting, + "rbd_default_map_options": defaultRBDMapOptions, } - - // Set network encryption monStore := config.GetMonStore(c.context, c.ClusterInfo) - if c.Spec.Network.Connections.Encryption != nil { - encryptionSetting := "crc secure" - // crc mode, if denied agree to secure mode - defaultRBDMapOptions := "ms_mode=prefer-crc" - if c.Spec.Network.Connections.Encryption.Enabled { - encryptionSetting = "secure" - defaultRBDMapOptions = "ms_mode=secure" - } - globalConfigSettings := map[string]string{ - "ms_cluster_mode": encryptionSetting, - "ms_service_mode": encryptionSetting, - "ms_client_mode": encryptionSetting, - "rbd_default_map_options": defaultRBDMapOptions, + // 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 { + encryptionConfig := []config.Option{} + for k := range encryptionGlobalConfigSettings { + encryptionConfig = append(encryptionConfig, config.Option{Who: "global", Option: k}) } - + 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", globalConfigSettings); err != nil { + if err := monStore.SetAll("global", encryptionGlobalConfigSettings); err != nil { return err } } // Set network compression - if c.Spec.Network.Connections.Compression != nil { - if c.ClusterInfo.CephVersion.IsAtLeastQuincy() { - compressionSetting := "none" - if c.Spec.Network.Connections.Compression.Enabled { - compressionSetting = "force" + if c.ClusterInfo.CephVersion.IsAtLeastQuincy() { + if c.Spec.Network.Connections == nil || c.Spec.Network.Connections.Compression == nil || !c.Spec.Network.Connections.Compression.Enabled { + encryptionConfig := []config.Option{ + {Who: "global", Option: "ms_osd_compress_mode"}, } + if err := monStore.DeleteAll(encryptionConfig...); err != nil { + return errors.Wrap(err, "failed to delete msgr2 compression settings") + } + } else { globalConfigSettings := map[string]string{ - "ms_osd_compress_mode": compressionSetting, + "ms_osd_compress_mode": "force", } - logger.Infof("setting msgr2 compression mode to %q", compressionSetting) + logger.Infof("setting msgr2 compression mode to %q", "force") if err := monStore.SetAll("global", globalConfigSettings); err != nil { return err } - } else { - logger.Warningf("network compression requires Ceph Quincy (v17) or newer, skipping for current ceph %q", c.ClusterInfo.CephVersion.String()) } + + } else { + logger.Warningf("network compression requires Ceph Quincy (v17) or newer, skipping for current ceph %q", c.ClusterInfo.CephVersion.String()) } + return nil } diff --git a/pkg/operator/ceph/cluster/cluster_test.go b/pkg/operator/ceph/cluster/cluster_test.go index 7d5ed9c8e..3cc94e585 100644 --- a/pkg/operator/ceph/cluster/cluster_test.go +++ b/pkg/operator/ceph/cluster/cluster_test.go @@ -183,6 +183,9 @@ func TestConfigureMsgr2(t *testing.T) { } return "", nil } + if args[0] == "config" && args[1] == "rm" { + return "", nil + } return "", errors.Errorf("unexpected ceph command %q", args) },