mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rbd: add validation to ToCSI() for rbdVolume and rbdSnapshot
After an unfortnate timed restart of the provisioner, a volume that got
cloned did not get a `rbdVolume.VolID` set. The `.VolID` is used as the
CSI Volume Handle, and is a required attribute.
The `rbdVolume` and `rbdSnapshot` structs have a `.ToCSI()` function
that can do the validation of required attributes. This is now added,
including unit-tests.
Signed-off-by: Niels de Vos <ndevos@ibm.com>
(cherry picked from commit ac8cda5e37
)
This commit is contained in:
committed by
mergify[bot]
parent
bd73674596
commit
63d64a8558
@ -244,6 +244,17 @@ func (cs *ControllerServer) parseVolCreateRequest(
|
||||
}
|
||||
|
||||
func (rbdVol *rbdVolume) ToCSI(ctx context.Context) (*csi.Volume, error) {
|
||||
switch {
|
||||
case rbdVol.VolID == "":
|
||||
return nil, fmt.Errorf("%q does not have a volume-id set", rbdVol)
|
||||
case rbdVol.Pool == "":
|
||||
return nil, fmt.Errorf("%q does not have a pool set", rbdVol)
|
||||
case rbdVol.JournalPool == "":
|
||||
return nil, fmt.Errorf("%q does not have a journal-pool set", rbdVol)
|
||||
case rbdVol.RbdImageName == "":
|
||||
return nil, fmt.Errorf("%q does not have an image-name set", rbdVol)
|
||||
}
|
||||
|
||||
vol := &csi.Volume{
|
||||
VolumeId: rbdVol.VolID,
|
||||
CapacityBytes: rbdVol.VolSize,
|
||||
|
Reference in New Issue
Block a user