mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-04-11 18:13:00 +00:00
rbd: prevent panic in CreateVolumeGroup if volumeID was not found
When an incorrect volumeID is passed while creating a VolumeGroup, the `.Destroy()` function caused a panic. By appending each volume to the volumes slice, the slice won't contain any `nil` volumes anymore. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
d10c83eeae
commit
45c91ab0f1
@ -89,7 +89,7 @@ func (vs *VolumeGroupServer) CreateVolumeGroup(
|
|||||||
defer mgr.Destroy(ctx)
|
defer mgr.Destroy(ctx)
|
||||||
|
|
||||||
// resolve all volumes
|
// resolve all volumes
|
||||||
volumes := make([]types.Volume, len(req.GetVolumeIds()))
|
volumes := make([]types.Volume, 0)
|
||||||
defer func() {
|
defer func() {
|
||||||
for _, vol := range volumes {
|
for _, vol := range volumes {
|
||||||
vol.Destroy(ctx)
|
vol.Destroy(ctx)
|
||||||
@ -105,7 +105,7 @@ func (vs *VolumeGroupServer) CreateVolumeGroup(
|
|||||||
req.GetName(),
|
req.GetName(),
|
||||||
err.Error())
|
err.Error())
|
||||||
}
|
}
|
||||||
volumes[i] = vol
|
volumes = append(volumes, vol)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.DebugLog(ctx, "all %d Volumes for VolumeGroup %q have been found", len(volumes), req.GetName())
|
log.DebugLog(ctx, "all %d Volumes for VolumeGroup %q have been found", len(volumes), req.GetName())
|
||||||
|
Loading…
Reference in New Issue
Block a user