Skip to content

Commit

Permalink
Merge pull request #354 from iPraveenParihar/bz/2303177
Browse files Browse the repository at this point in the history
BUG 2303177: util: exclude empty label values for crushlocation map
  • Loading branch information
openshift-merge-bot[bot] authored Sep 2, 2024
2 parents 0eefc0d + a0af06c commit a342487
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/util/crushlocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func getCrushLocationMap(crushLocationLabels string, nodeLabels map[string]strin
// Determine values for requested labels from node labels
crushLocationMap := make(map[string]string, len(labelsIn))
for key, value := range nodeLabels {
// label with empty value is not considered.
if value == "" {
continue
}
if _, ok := labelsIn[key]; !ok {
continue
}
Expand Down
11 changes: 11 additions & 0 deletions internal/util/crushlocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ func Test_getCrushLocationMap(t *testing.T) {
},
want: map[string]string{"host": "worker-1"},
},
{
name: "matching crushlocation and node labels with empty value",
args: input{
crushLocationLabels: "topology.io/region,topology.io/zone",
nodeLabels: map[string]string{
"topology.io/region": "region1",
"topology.io/zone": "",
},
},
want: map[string]string{"region": "region1"},
},
}
for _, tt := range tests {
currentTT := tt
Expand Down

0 comments on commit a342487

Please sign in to comment.