mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-05-24 08:16:42 +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> (cherry picked from commit 6d14eeee70b7fb99e23723fe5164cb414d4caff6)
This commit is contained in:
parent
96fce60b4e
commit
a17eb07947
@ -1566,3 +1566,31 @@ func (ri *rbdImage) isCompatibleThickProvision(dst *rbdVolume) error {
|
||||
|
||||
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…
x
Reference in New Issue
Block a user