diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 8d6016ea9..28ac9cf7d 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -572,6 +572,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -7406,6 +7407,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -7594,6 +7596,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -11258,6 +11261,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -12858,6 +12862,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -13817,6 +13822,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -14000,6 +14006,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 7b12caf94..d34ad9a60 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -574,6 +574,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -7401,6 +7402,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -7589,6 +7591,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -11249,6 +11252,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -12849,6 +12853,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -13805,6 +13810,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size @@ -13988,6 +13994,7 @@ spec: type: string targetSizeRatio: description: TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + minimum: 0 type: number required: - size diff --git a/pkg/apis/ceph.rook.io/v1/pool.go b/pkg/apis/ceph.rook.io/v1/pool.go index 2ebe92374..a3653f04d 100644 --- a/pkg/apis/ceph.rook.io/v1/pool.go +++ b/pkg/apis/ceph.rook.io/v1/pool.go @@ -32,14 +32,6 @@ func (p *PoolSpec) IsHybridStoragePool() bool { return p.Replicated.HybridStorage != nil } -func (p *PoolSpec) IsCompressionEnabled() bool { - return p.CompressionMode != "" -} - -func (p *ReplicatedSpec) IsTargetRatioEnabled() bool { - return p.TargetSizeRatio != 0 -} - // ValidateCephBlockPool validates specifically a CephBlockPool's spec (not just any NamedPoolSpec) func ValidateCephBlockPool(p *CephBlockPool) error { if p.Spec.Name == ".rgw.root" || p.Spec.Name == ".mgr" || p.Spec.Name == ".nfs" { diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 2aca1344f..04bd2ed25 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -1159,6 +1159,7 @@ type ReplicatedSpec struct { Size uint `json:"size"` // TargetSizeRatio gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity + // +kubebuilder:validation:Minimum=0 // +optional TargetSizeRatio float64 `json:"targetSizeRatio,omitempty"` diff --git a/pkg/daemon/ceph/client/pool.go b/pkg/daemon/ceph/client/pool.go index 036730b99..e4ab2c5a9 100644 --- a/pkg/daemon/ceph/client/pool.go +++ b/pkg/daemon/ceph/client/pool.go @@ -326,11 +326,11 @@ func setCommonPoolProperties(context *clusterd.Context, clusterInfo *ClusterInfo pool.Parameters = make(map[string]string) } - if pool.Replicated.IsTargetRatioEnabled() { + if _, ok := pool.Parameters[targetSizeRatioProperty]; !ok { pool.Parameters[targetSizeRatioProperty] = strconv.FormatFloat(pool.Replicated.TargetSizeRatio, 'f', -1, 32) } - if pool.IsCompressionEnabled() { + if _, ok := pool.Parameters[CompressionModeProperty]; !ok && pool.CompressionMode != "" { pool.Parameters[CompressionModeProperty] = pool.CompressionMode } diff --git a/pkg/operator/ceph/file/filesystem_test.go b/pkg/operator/ceph/file/filesystem_test.go index bd4661873..1e9d24c5b 100644 --- a/pkg/operator/ceph/file/filesystem_test.go +++ b/pkg/operator/ceph/file/filesystem_test.go @@ -308,6 +308,22 @@ func fsExecutor(t *testing.T, fsName, configDir string, multiFS bool, createData return "", nil } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "size", "1"}) { return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-metadata", "target_size_ratio", "0"}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data0", "target_size_ratio", "0"}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "target_size_ratio", "0"}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-named-pool", "target_size_ratio", "0"}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-metadata", "compression_mode", ""}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data0", "compression_mode", ""}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "compression_mode", ""}) { + return "", nil + } else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-named-pool", "compression_mode", ""}) { + return "", nil } else if reflect.DeepEqual(args[0:4], []string{"fs", "add_data_pool", fsName, fsName + "-data1"}) { *addDataPoolCount++ return "", nil