mon: disable insecure global ids for new deployments

In new deployments we always want to disable the insecure global id.
If the mgr deployment is newly created, we know it's a new cluster
and the mons are in quorum, so we can go ahead and disable the
insecure global IDs.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 28957b3ff1)
This commit is contained in:
Travis Nielsen authored and Mergify committed 2022-06-27 21:54:07 +00:00
1 parent 9f42987feb
commit 6d9ecf48bc
5 files changed
+53 -6

No files matched your search

+1 -6
View File
@@ -166,12 +166,7 @@ func (c *cephStatusChecker) configureHealthSettings(status cephclient.CephStatus
if _, ok := status.Health.Checks["AUTH_INSECURE_GLOBAL_ID_RECLAIM_ALLOWED"]; ok {
if _, ok := status.Health.Checks["AUTH_INSECURE_GLOBAL_ID_RECLAIM"]; !ok {
logger.Info("Disabling the insecure global ID as no legacy clients are currently connected. If you still require the insecure connections, see the CVE to suppress the health warning and re-enable the insecure connections. https://docs.ceph.com/en/latest/security/CVE-2021-20288/")
monStore := config.GetMonStore(c.context, c.clusterInfo)
if err := monStore.Set("mon", "auth_allow_insecure_global_id_reclaim", "false"); err != nil {
logger.Warningf("failed to disable the insecure global ID. %v", err)
} else {
logger.Info("insecure global ID is now disabled")
}
config.DisableInsecureGlobalID(c.context, c.clusterInfo)
} else {
logger.Warning("insecure clients are connected to the cluster, to resolve the AUTH_INSECURE_GLOBAL_ID_RECLAIM health warning please refer to the upgrade guide to ensure all Ceph daemons are updated.")
}
@@ -29,6 +29,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
"github.com/rook/rook/pkg/operator/ceph/version"
optest "github.com/rook/rook/pkg/operator/test"
exectest "github.com/rook/rook/pkg/util/exec/test"
"github.com/stretchr/testify/assert"
@@ -161,6 +162,7 @@ func TestConfigureHealthSettings(t *testing.T) {
context: &clusterd.Context{},
clusterInfo: cephclient.AdminTestClusterInfo("ns"),
}
c.clusterInfo.CephVersion = version.Quincy
setGlobalIDReclaim := false
c.context.Executor = &exectest.MockExecutor{
MockExecuteCommandWithTimeout: func(timeout time.Duration, command string, args ...string) (string, error) {
+6
View File
@@ -160,6 +160,12 @@ func (c *Cluster) Start() error {
}
}
// Insecure global IDs should be disabled for new clusters immediately.
// If we're waiting for the mgr deployments to start, it is a clean deployment
if len(deploymentsToWaitFor) > 0 {
config.DisableInsecureGlobalID(c.context, c.clusterInfo)
}
// If the mgr is newly created, wait for it to start before continuing with the service and
// module configuration
for _, d := range deploymentsToWaitFor {
+29
View File
@@ -29,6 +29,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
"github.com/rook/rook/pkg/operator/ceph/version"
)
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "op-config")
@@ -161,3 +162,31 @@ func SetOrRemoveDefaultConfigs(
return nil
}
func DisableInsecureGlobalID(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo) {
if !canDisableInsecureGlobalID(clusterInfo) {
logger.Infof("cannot disable insecure global id on ceph version %v", clusterInfo.CephVersion.String())
return
}
monStore := GetMonStore(context, clusterInfo)
if err := monStore.Set("mon", "auth_allow_insecure_global_id_reclaim", "false"); err != nil {
logger.Warningf("failed to disable the insecure global ID. %v", err)
} else {
logger.Info("insecure global ID is now disabled")
}
}
func canDisableInsecureGlobalID(clusterInfo *cephclient.ClusterInfo) bool {
cephver := clusterInfo.CephVersion
if cephver.IsAtLeastQuincy() {
return true
}
if cephver.IsPacific() && cephver.IsAtLeast(version.CephVersion{Major: 16, Minor: 2, Extra: 1}) {
return true
}
if cephver.IsOctopus() && cephver.IsAtLeast(version.CephVersion{Major: 15, Minor: 2, Extra: 11}) {
return true
}
return false
}
+15
View File
@@ -19,6 +19,8 @@ package config
import (
"testing"
"github.com/rook/rook/pkg/daemon/ceph/client"
"github.com/rook/rook/pkg/operator/ceph/version"
"github.com/stretchr/testify/assert"
)
@@ -29,3 +31,16 @@ func TestNewFlag(t *testing.T) {
assert.Equal(t, NewFlag("c key", "c"), "--c-key=c")
assert.Equal(t, NewFlag("quotes", "\"quoted\""), "--quotes=\"quoted\"")
}
func TestInsecureGlobalIDVersion(t *testing.T) {
c := &client.ClusterInfo{CephVersion: version.CephVersion{Major: 17, Minor: 2, Extra: 0}}
assert.True(t, canDisableInsecureGlobalID(c))
c = &client.ClusterInfo{CephVersion: version.CephVersion{Major: 16, Minor: 2, Extra: 0}}
assert.False(t, canDisableInsecureGlobalID(c))
c = &client.ClusterInfo{CephVersion: version.CephVersion{Major: 16, Minor: 2, Extra: 1}}
assert.True(t, canDisableInsecureGlobalID(c))
c = &client.ClusterInfo{CephVersion: version.CephVersion{Major: 15, Minor: 2, Extra: 10}}
assert.False(t, canDisableInsecureGlobalID(c))
c = &client.ClusterInfo{CephVersion: version.CephVersion{Major: 15, Minor: 2, Extra: 11}}
assert.True(t, canDisableInsecureGlobalID(c))
}