Skip to content

Commit

Permalink
Merge pull request #14325 from ideepika/wip-solve-device-class-bug
Browse files Browse the repository at this point in the history
pool: get the exact deviceClass name instead of crushroot+deviceClass
  • Loading branch information
travisn committed Jun 12, 2024
2 parents dafcb76 + 41116be commit 720c23a
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 720c23a

Please sign in to comment.