csi: fix panic in serializing nil allocs in volume API (#8735)
- fix panic in serializing nil allocs in volume API - prevent potential panic in serializing plugin allocs
This commit is contained in:
parent
95bae2e6ca
commit
f9b6c8153c
|
@ -296,7 +296,9 @@ func structsCSIPluginToApi(plug *structs.CSIPlugin) *api.CSIPlugin {
|
|||
}
|
||||
|
||||
for _, a := range plug.Allocations {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a))
|
||||
if a != nil {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a))
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
|
@ -341,11 +343,15 @@ func structsCSIVolumeToApi(vol *structs.CSIVolume) *api.CSIVolume {
|
|||
}
|
||||
|
||||
for _, a := range vol.WriteAllocs {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a.Stub()))
|
||||
if a != nil {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a.Stub()))
|
||||
}
|
||||
}
|
||||
|
||||
for _, a := range vol.ReadAllocs {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a.Stub()))
|
||||
if a != nil {
|
||||
out.Allocations = append(out.Allocations, structsAllocListStubToApi(a.Stub()))
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
|
|
Loading…
Reference in a new issue