Skip to content

Commit

Permalink
pool: get the exact deviceClass name instead of crushroot+deviceClass
Browse files Browse the repository at this point in the history
this lead to creation of 2 crush rules because of difference in
deviceClass names:
eg:
creating a new crush rule for changed deviceClass
("default~hdd"-->"hdd") on crush rule "test-crush-bug-az-ab-4"

Signed-off-by: Deepika Upadhyay <deepikaupadhyay01@gmail.com>
  • Loading branch information
Deepika Upadhyay committed Jun 12, 2024
1 parent ff448e1 commit 41116be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/daemon/ceph/client/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,15 @@ func extractPoolDetails(rule ruleSpec) (string, string) {
failureDomain = step.Type
}
if step.ItemName != "" {
deviceClass = step.ItemName
// we are not using crushRoot currently, remove it
// from crush rule
if strings.Contains(step.ItemName, "~") {
crushRootAndDeviceClass := step.ItemName
parts := strings.SplitN(crushRootAndDeviceClass, "~", 2)
deviceClass = parts[1]
} else {
deviceClass = step.ItemName
}
}
// We expect the rule to be found by the second step, or else it is a more
// complex rule that would not be supported for updating the failure domain
Expand Down
10 changes: 10 additions & 0 deletions pkg/daemon/ceph/client/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ func TestExtractPoolDetails(t *testing.T) {
assert.Equal(t, "zone", failureDomain)
assert.Equal(t, "ssd", deviceClass)
})

t.Run("valid crush rule with crushroot combined", func(t *testing.T) {
rule := ruleSpec{Steps: []stepSpec{
{Type: ""},
{Type: "zone", ItemName: "default~ssd"},
}}
failureDomain, deviceClass := extractPoolDetails(rule)
assert.Equal(t, "zone", failureDomain)
assert.Equal(t, "ssd", deviceClass)
})
}

func TestGetPoolStatistics(t *testing.T) {
Expand Down

0 comments on commit 41116be

Please sign in to comment.