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

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>
(cherry picked from commit 41116be919)
This commit is contained in:
Deepika Upadhyay authored and Mergify committed 2024-06-12 22:14:34 +00:00
1 parent dbe24136ca
commit 222776b2f1
2 files changed
+19 -1

No files matched your search

+9 -1
View File
@@ -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
+10
View File
@@ -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) {