From b92bbba6714ba6d9a0f1b44f076efa16cb44c730 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 10 Jul 2024 10:44:15 -0600 Subject: [PATCH] pool: skip updating crush rules for stretch clusters Pools in stretch clusters must all specify the same CRUSH rule. No pools can use a different rule. When there is a change in the device class, we do not even expect to update the crush rules in a stretch cluster. Different device classes are not supported in stretch clusters, and it's expected to be a homogenous environment. Therefore, skip all crush rule updates in stretch clusters. Signed-off-by: Travis Nielsen --- pkg/daemon/ceph/client/pool.go | 4 ++++ pkg/daemon/ceph/client/pool_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pkg/daemon/ceph/client/pool.go b/pkg/daemon/ceph/client/pool.go index 4677007fd..95d778ec8 100644 --- a/pkg/daemon/ceph/client/pool.go +++ b/pkg/daemon/ceph/client/pool.go @@ -468,6 +468,10 @@ func updatePoolCrushRule(context *clusterd.Context, clusterInfo *ClusterInfo, cl logger.Debugf("Skipping crush rule update for pool %q: EnableCrushUpdates is disabled", pool.Name) return nil } + if clusterSpec.IsStretchCluster() { + logger.Debugf("skipping crush rule update for pool %q in a stretch cluster", pool.Name) + return nil + } if pool.FailureDomain == "" && pool.DeviceClass == "" { logger.Debugf("skipping check for failure domain and deviceClass on pool %q as it is not specified", pool.Name) diff --git a/pkg/daemon/ceph/client/pool_test.go b/pkg/daemon/ceph/client/pool_test.go index db29c2686..28bacae21 100644 --- a/pkg/daemon/ceph/client/pool_test.go +++ b/pkg/daemon/ceph/client/pool_test.go @@ -251,10 +251,12 @@ func TestUpdateFailureDomain(t *testing.T) { currentFailureDomain := "rack" currentDeviceClass := "default" testCrushRuleName := "test_rule" + cephCommandCalled := false executor := &exectest.MockExecutor{} context := &clusterd.Context{Executor: executor} executor.MockExecuteCommandWithOutput = func(command string, args ...string) (string, error) { logger.Infof("Command: %s %v", command, args) + cephCommandCalled = true if args[1] == "pool" { if args[2] == "get" { assert.Equal(t, "mypool", args[3]) @@ -335,6 +337,27 @@ func TestUpdateFailureDomain(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "mypool_zone", newCrushRule) }) + + t.Run("stretch cluster skips crush rule update", func(t *testing.T) { + p := cephv1.NamedPoolSpec{ + Name: "mypool", + PoolSpec: cephv1.PoolSpec{ + FailureDomain: "zone", + Replicated: cephv1.ReplicatedSpec{Size: 3}, + EnableCrushUpdates: true, + }, + } + clusterSpec := &cephv1.ClusterSpec{ + Mon: cephv1.MonSpec{StretchCluster: &cephv1.StretchClusterSpec{Zones: []cephv1.MonZoneSpec{{Name: "zone1"}, {Name: "zone2"}, {Name: "zone3", Arbiter: true}}}}, + Storage: cephv1.StorageScopeSpec{}, + } + newCrushRule = "" + cephCommandCalled = false + err := updatePoolCrushRule(context, AdminTestClusterInfo("mycluster"), clusterSpec, p) + assert.NoError(t, err) + assert.Equal(t, "", newCrushRule) + assert.False(t, cephCommandCalled) + }) } func TestExtractPoolDetails(t *testing.T) {