mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
util: exclude empty label values for crushlocation map
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 <m.praveen@ibm.com>
(cherry picked from commit f11fa815c8
)
This commit is contained in:
parent
47d17c9443
commit
6753bbfba3
@ -48,6 +48,10 @@ func getCrushLocationMap(crushLocationLabels string, nodeLabels map[string]strin
|
|||||||
// Determine values for requested labels from node labels
|
// Determine values for requested labels from node labels
|
||||||
crushLocationMap := make(map[string]string, len(labelsIn))
|
crushLocationMap := make(map[string]string, len(labelsIn))
|
||||||
for key, value := range nodeLabels {
|
for key, value := range nodeLabels {
|
||||||
|
// label with empty value is not considered.
|
||||||
|
if value == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := labelsIn[key]; !ok {
|
if _, ok := labelsIn[key]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,17 @@ func Test_getCrushLocationMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: map[string]string{"host": "worker-1"},
|
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 {
|
for _, tt := range tests {
|
||||||
currentTT := tt
|
currentTT := tt
|
||||||
|
Loading…
Reference in New Issue
Block a user