Merge pull request #17447 from subhamkrai/add-stipe-unit-support

pool: add stripe_unit with erasure-code-profile set
This commit is contained in:
Travis Nielsen authored and GitHub committed 2026-05-14 10:38:06 -06:00
commit 2ef74f3189
7 files changed
+252 -1

No files matched your search

+13
View File
@@ -7169,6 +7169,19 @@ string
If absent, defaults to the plugin specified in osd_pool_default_erasure_code_profile.</p>
</td>
</tr>
<tr>
<td>
<code>stripeUnit</code><br/>
<em>
k8s.io/apimachinery/pkg/api/resource.Quantity
</em>
</td>
<td>
<em>(Optional)</em>
<p>Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).</p>
</td>
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.ExternalSpec">ExternalSpec
@@ -475,6 +475,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7762,6 +7777,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7957,6 +7987,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -12886,6 +12931,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -14528,6 +14588,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15597,6 +15672,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15787,6 +15877,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
+105
View File
@@ -477,6 +477,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7757,6 +7772,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7952,6 +7982,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -12875,6 +12920,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -14517,6 +14577,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15583,6 +15658,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15773,6 +15863,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
stripeUnit:
anyOf:
- type: integer
- type: string
description: |-
Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
Value must be a multiple of 4096 (4Ki).
enum:
- 4Ki
- 16Ki
- 64Ki
- 256Ki
- 1Mi
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
+6
View File
@@ -1429,6 +1429,12 @@ type ErasureCodedSpec struct {
// +kubebuilder:validation:Enum=isa;jerasure
// +optional
Algorithm string `json:"algorithm,omitempty"`
// Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
// Value must be a multiple of 4096 (4Ki).
// +kubebuilder:validation:Enum={"4Ki","16Ki","64Ki","256Ki","1Mi"}
// +optional
StripeUnit *resource.Quantity `json:"stripeUnit,omitempty"`
}
// +genclient
@@ -2690,6 +2690,11 @@ func (in *EndpointAddress) DeepCopy() *EndpointAddress {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ErasureCodedSpec) DeepCopyInto(out *ErasureCodedSpec) {
*out = *in
if in.StripeUnit != nil {
in, out := &in.StripeUnit, &out.StripeUnit
x := (*in).DeepCopy()
*out = &x
}
return
}
@@ -4922,7 +4927,7 @@ func (in *PoolSpec) DeepCopyInto(out *PoolSpec) {
**out = **in
}
in.Replicated.DeepCopyInto(&out.Replicated)
out.ErasureCoded = in.ErasureCoded
in.ErasureCoded.DeepCopyInto(&out.ErasureCoded)
if in.Parameters != nil {
in, out := &in.Parameters, &out.Parameters
*out = make(map[string]string, len(*in))
@@ -92,6 +92,13 @@ func CreateErasureCodeProfile(context *clusterd.Context, clusterInfo *ClusterInf
if pool.DeviceClass != "" {
profilePairs = append(profilePairs, fmt.Sprintf("crush-device-class=%s", pool.DeviceClass))
}
if pool.ErasureCoded.StripeUnit != nil && !pool.ErasureCoded.StripeUnit.IsZero() {
stripeBytes, ok := pool.ErasureCoded.StripeUnit.AsInt64()
if !ok {
return errors.Errorf("erasure-coded stripeUnit %q cannot be represented as a byte stripe for Ceph", pool.ErasureCoded.StripeUnit.String())
}
profilePairs = append(profilePairs, fmt.Sprintf("stripe_unit=%d", stripeBytes))
}
args := []string{"osd", "erasure-code-profile", "set", profileName, "--force"}
args = append(args, profilePairs...)
@@ -23,6 +23,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
exectest "github.com/rook/rook/pkg/util/exec/test"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/api/resource"
"github.com/rook/rook/pkg/clusterd"
)
@@ -40,6 +41,7 @@ func TestCreateProfileWithDeviceClass(t *testing.T) {
}
func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass string) {
stripeUnit := resource.MustParse("4Ki")
spec := cephv1.PoolSpec{
FailureDomain: failureDomain,
CrushRoot: crushRoot,
@@ -47,6 +49,7 @@ func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass strin
ErasureCoded: cephv1.ErasureCodedSpec{
DataChunks: 2,
CodingChunks: 3,
StripeUnit: &stripeUnit,
},
}
@@ -77,6 +80,13 @@ func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass strin
}
if deviceClass != "" {
assert.Equal(t, fmt.Sprintf("crush-device-class=%s", deviceClass), args[nextArg])
nextArg++
}
if spec.ErasureCoded.StripeUnit != nil && !spec.ErasureCoded.StripeUnit.IsZero() {
stripeBytes, ok := spec.ErasureCoded.StripeUnit.AsInt64()
assert.True(t, ok)
assert.Equal(t, fmt.Sprintf("stripe_unit=%d", stripeBytes), args[nextArg])
assert.Equal(t, stripeBytes, int64(4096), "Validate the resource conversion to bytes")
}
return "", nil
}