pool: allow negative step num in crush rule

The crush rules may have a negative step num.
Rook had assumed negative values were not possible,
but just had not been encountered previously in
a custom crush rule.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit b9188c793a)
This commit is contained in:
Travis Nielsen authored and Mergify committed 2024-09-10 13:58:34 +00:00
1 parent 1a1daf6bff
commit 63e7c8125d
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -75,7 +75,7 @@ type ruleSpec struct {
type stepSpec struct {
Operation string `json:"op"`
Number uint `json:"num"`
Number int `json:"num"`
Item int `json:"item"`
ItemName string `json:"item_name"`
Type string `json:"type"`
+1 -1
View File
@@ -150,7 +150,7 @@ func buildTwoStepCrushSteps(pool cephv1.PoolSpec) []stepSpec {
// Step three
stepTakeSubFailureDomain := &stepSpec{
Operation: "chooseleaf_firstn",
Number: pool.Replicated.ReplicasPerFailureDomain,
Number: int(pool.Replicated.ReplicasPerFailureDomain),
Type: pool.Replicated.SubFailureDomain,
}
steps = append(steps, *stepTakeSubFailureDomain)
+1 -1
View File
@@ -56,7 +56,7 @@ func TestBuildCrushSteps(t *testing.T) {
assert.Equal(t, 4, len(steps))
assert.Equal(t, cephv1.DefaultCRUSHRoot, steps[0].ItemName)
assert.Equal(t, "datacenter", steps[1].Type)
assert.Equal(t, uint(2), steps[2].Number)
assert.Equal(t, 2, steps[2].Number)
}
func TestCompileCRUSHMap(t *testing.T) {