Merge pull request #15951 from OdedViner/target_size_ratio_negative

pool: support targetSizeRatio=0 and default compressionMode=""
This commit is contained in:
Travis Nielsen
2025-06-11 07:35:24 -06:00
committed by GitHub
6 changed files with 33 additions and 10 deletions
@@ -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
+7
View File
@@ -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
-8
View File
@@ -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" {
+1
View File
@@ -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"`
+2 -2
View File
@@ -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
}
+16
View File
@@ -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