mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
rbd: use RbdSnapName to check the image details
RbdSnapName holds the actual RBD image name which got created during the CreateSnapshot operation. RbdImageName holds the name of the parent from which the snapshot is created. and the parent is independent of snapshot and it can be deleted any time for the same reason using the RbdSnapName to check the rbd image details. generate a temporary volume from the snapshot which replaces the rbdImageName with RbdSnapName and use it to check the image metadata. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
7966d2e5c1
commit
6d14eeee70
@ -1629,3 +1629,31 @@ func (ri *rbdImage) isCompatibleThickProvision(dst *rbdVolume) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: merge isCompatibleThickProvision of rbdSnapshot and rbdImage to a single
|
||||||
|
// function.
|
||||||
|
func (rs *rbdSnapshot) isCompatibleThickProvision(dst *rbdVolume) error {
|
||||||
|
// During CreateSnapshot the rbd image will be created with the
|
||||||
|
// snapshot name. Replacing RbdImageName with RbdSnapName so that we
|
||||||
|
// can check if the image is thick provisioned
|
||||||
|
vol := generateVolFromSnap(rs)
|
||||||
|
err := vol.Connect(rs.conn.Creds)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer vol.Destroy()
|
||||||
|
|
||||||
|
thick, err := vol.isThickProvisioned()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case thick && !dst.ThickProvision:
|
||||||
|
return fmt.Errorf("cannot create thin volume from thick volume %q", vol)
|
||||||
|
|
||||||
|
case !thick && dst.ThickProvision:
|
||||||
|
return fmt.Errorf("cannot create thick volume from thin volume %q", vol)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user