Skip to content

Commit

Permalink
util: exclude empty label values for crushlocation map
Browse files Browse the repository at this point in the history
This commit resolves a bug where node labels with empty values
are processed for the crush_location mount option,
leading to invalid mount options and subsequent mount failures.

Signed-off-by: Praveen M <[email protected]>
  • Loading branch information
iPraveenParihar authored and mergify[bot] committed Jul 16, 2024
1 parent 3dd7e8b commit f11fa81
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 {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit f11fa81

Please sign in to comment.