mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +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>
This commit is contained in:
committed by
mergify[bot]
parent
b3faa04504
commit
ac8cda5e37
@ -147,6 +147,13 @@ func (rbdSnap *rbdSnapshot) toVolume() *rbdVolume {
|
||||
}
|
||||
|
||||
func (rbdSnap *rbdSnapshot) ToCSI(ctx context.Context) (*csi.Snapshot, error) {
|
||||
switch {
|
||||
case rbdSnap.VolID == "":
|
||||
return nil, fmt.Errorf("%q does not have a volume-id set", rbdSnap)
|
||||
case rbdSnap.SourceVolumeID == "":
|
||||
return nil, fmt.Errorf("%q does not have a source-volume-id set", rbdSnap)
|
||||
}
|
||||
|
||||
created, err := rbdSnap.GetCreationTime(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user