Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: get the exact deviceClass name instead of crushroot+deviceClass #14325

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 != "" {
travisn marked this conversation as resolved.
Show resolved Hide resolved
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
Loading