From df49ca1247ed2ef8a84448460c5a19dc4ea2233a Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Thu, 11 Sep 2025 16:29:30 -0600 Subject: [PATCH] pool: allow enablecrushupdates to be nil Enabling crush updates is false by default, and can be enabled if set to true. The setting needs to be nullable in case we need to differentiate between the value being set to false or just not set, to know if the default should be different. This is necessary for rook consumers who are refererencing the pool struct and want to change the default, rather than using rook's default value of false. Signed-off-by: Travis Nielsen --- deploy/charts/rook-ceph/templates/resources.yaml | 7 +++++++ deploy/examples/crds.yaml | 7 +++++++ pkg/apis/ceph.rook.io/v1/types.go | 3 ++- pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go | 5 +++++ pkg/daemon/ceph/client/pool.go | 2 +- pkg/daemon/ceph/client/pool_test.go | 9 +++++---- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 8f2eb4944..92a09e2a6 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -446,6 +446,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -7675,6 +7676,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -7869,6 +7871,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -11607,6 +11610,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -13220,6 +13224,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -14188,6 +14193,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -14377,6 +14383,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 506aae257..02f4c63e3 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -448,6 +448,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -7670,6 +7671,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -7864,6 +7866,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -11598,6 +11601,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -13211,6 +13215,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -14176,6 +14181,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool @@ -14365,6 +14371,7 @@ spec: type: string enableCrushUpdates: description: Allow rook operator to change the pool CRUSH tunables once the pool is created + nullable: true type: boolean enableRBDStats: description: EnableRBDStats is used to enable gathering of statistics for all RBD images in the pool diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index ffb2f9512..ccfc70dc6 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -948,8 +948,9 @@ type PoolSpec struct { DeviceClass string `json:"deviceClass,omitempty"` // Allow rook operator to change the pool CRUSH tunables once the pool is created + // +nullable // +optional - EnableCrushUpdates bool `json:"enableCrushUpdates,omitempty"` + EnableCrushUpdates *bool `json:"enableCrushUpdates,omitempty"` // DEPRECATED: use Parameters instead, e.g., Parameters["compression_mode"] = "force" // The inline compression mode in Bluestore OSD to set to (options are: none, passive, aggressive, force) diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index adeefa444..92a52dded 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -4552,6 +4552,11 @@ func (in *PoolPlacementSpec) DeepCopy() *PoolPlacementSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PoolSpec) DeepCopyInto(out *PoolSpec) { *out = *in + if in.EnableCrushUpdates != nil { + in, out := &in.EnableCrushUpdates, &out.EnableCrushUpdates + *out = new(bool) + **out = **in + } in.Replicated.DeepCopyInto(&out.Replicated) out.ErasureCoded = in.ErasureCoded if in.Parameters != nil { diff --git a/pkg/daemon/ceph/client/pool.go b/pkg/daemon/ceph/client/pool.go index 4e673beab..0f8981250 100644 --- a/pkg/daemon/ceph/client/pool.go +++ b/pkg/daemon/ceph/client/pool.go @@ -510,7 +510,7 @@ func createReplicatedPoolForApp(context *clusterd.Context, clusterInfo *ClusterI } func updatePoolCrushRule(context *clusterd.Context, clusterInfo *ClusterInfo, clusterSpec *cephv1.ClusterSpec, pool cephv1.NamedPoolSpec) error { - if !pool.EnableCrushUpdates { + if pool.EnableCrushUpdates == nil || !*pool.EnableCrushUpdates { logger.Debugf("Skipping crush rule update for pool %q: EnableCrushUpdates is disabled", pool.Name) return nil } diff --git a/pkg/daemon/ceph/client/pool_test.go b/pkg/daemon/ceph/client/pool_test.go index 556da669e..f68872190 100644 --- a/pkg/daemon/ceph/client/pool_test.go +++ b/pkg/daemon/ceph/client/pool_test.go @@ -286,12 +286,13 @@ func TestUpdateFailureDomain(t *testing.T) { return "", errors.Errorf("unexpected ceph command %q", args) } + enableCrushUpdates := true t.Run("no desired failure domain", func(t *testing.T) { p := cephv1.NamedPoolSpec{ Name: "mypool", PoolSpec: cephv1.PoolSpec{ Replicated: cephv1.ReplicatedSpec{Size: 3}, - EnableCrushUpdates: true, + EnableCrushUpdates: &enableCrushUpdates, }, } clusterSpec := &cephv1.ClusterSpec{Storage: cephv1.StorageScopeSpec{}} @@ -306,7 +307,7 @@ func TestUpdateFailureDomain(t *testing.T) { PoolSpec: cephv1.PoolSpec{ FailureDomain: currentFailureDomain, Replicated: cephv1.ReplicatedSpec{Size: 3}, - EnableCrushUpdates: true, + EnableCrushUpdates: &enableCrushUpdates, }, } testCrushRuleName = "mypool_rack" @@ -336,7 +337,7 @@ func TestUpdateFailureDomain(t *testing.T) { PoolSpec: cephv1.PoolSpec{ FailureDomain: "zone", Replicated: cephv1.ReplicatedSpec{Size: 3}, - EnableCrushUpdates: true, + EnableCrushUpdates: &enableCrushUpdates, }, } clusterSpec := &cephv1.ClusterSpec{Storage: cephv1.StorageScopeSpec{}} @@ -351,7 +352,7 @@ func TestUpdateFailureDomain(t *testing.T) { PoolSpec: cephv1.PoolSpec{ FailureDomain: "zone", Replicated: cephv1.ReplicatedSpec{Size: 3}, - EnableCrushUpdates: true, + EnableCrushUpdates: &enableCrushUpdates, }, } clusterSpec := &cephv1.ClusterSpec{