mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: add validation for thick restore/clone
added validation to allow only Restore of Thick PVC snapshot to a thick clone and creation of thick clone from thick PVC. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
fc442221e4
commit
7966d2e5c1
@ -222,11 +222,21 @@ func checkValidCreateVolumeRequest(rbdVol, parentVol *rbdVolume, rbdSnap *rbdSna
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.InvalidArgument, "cannot restore from snapshot %s: %s", rbdSnap, err.Error())
|
return status.Errorf(codes.InvalidArgument, "cannot restore from snapshot %s: %s", rbdSnap, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = rbdSnap.isCompatibleThickProvision(rbdVol)
|
||||||
|
if err != nil {
|
||||||
|
return status.Errorf(codes.InvalidArgument, "cannot restore from snapshot %s: %s", rbdSnap, err.Error())
|
||||||
|
}
|
||||||
case parentVol != nil:
|
case parentVol != nil:
|
||||||
err = parentVol.isCompatibleEncryption(&rbdVol.rbdImage)
|
err = parentVol.isCompatibleEncryption(&rbdVol.rbdImage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.InvalidArgument, "cannot clone from volume %s: %s", parentVol, err.Error())
|
return status.Errorf(codes.InvalidArgument, "cannot clone from volume %s: %s", parentVol, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = parentVol.isCompatibleThickProvision(rbdVol)
|
||||||
|
if err != nil {
|
||||||
|
return status.Errorf(codes.InvalidArgument, "cannot clone from volume %s: %s", parentVol, err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1613,3 +1613,19 @@ func (ri *rbdImage) isCompatibleEncryption(dst *rbdImage) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ri *rbdImage) isCompatibleThickProvision(dst *rbdVolume) error {
|
||||||
|
thick, err := ri.isThickProvisioned()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case thick && !dst.ThickProvision:
|
||||||
|
return fmt.Errorf("cannot create thin volume from thick volume %q", ri)
|
||||||
|
|
||||||
|
case !thick && dst.ThickProvision:
|
||||||
|
return fmt.Errorf("cannot create thick volume from thin volume %q", ri)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user