mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: introduce rbdImage as base for rbdVolume and rbdSnapshot
Because rbdVolume and rbdSnapshot are very similar, they can be based off a common struct rbdImage that contains the common attributes and functions. This makes it possible to re-use functions for snapshots, and prevents further duplication or code. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
3fe714c4fa
commit
10a75dd4ff
@ -46,10 +46,10 @@ import (
|
||||
func (rv *rbdVolume) checkCloneImage(ctx context.Context, parentVol *rbdVolume) (bool, error) {
|
||||
// generate temp cloned volume
|
||||
tempClone := rv.generateTempClone()
|
||||
snap := &rbdSnapshot{
|
||||
RbdSnapName: rv.RbdImageName,
|
||||
Pool: rv.Pool,
|
||||
}
|
||||
snap := &rbdSnapshot{}
|
||||
snap.RbdSnapName = rv.RbdImageName
|
||||
snap.Pool = rv.Pool
|
||||
|
||||
// check if cloned image exists
|
||||
err := rv.getImageInfo()
|
||||
if err == nil {
|
||||
@ -145,18 +145,17 @@ func (rv *rbdVolume) generateTempClone() *rbdVolume {
|
||||
func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVolume) error {
|
||||
// generate temp cloned volume
|
||||
tempClone := rv.generateTempClone()
|
||||
tempSnap := &rbdSnapshot{
|
||||
// snapshot name is same as temporary cloned image, This helps to
|
||||
// flatten the temporary cloned images as we cannot have more than 510
|
||||
// snapshots on an rbd image
|
||||
RbdSnapName: tempClone.RbdImageName,
|
||||
Pool: rv.Pool,
|
||||
}
|
||||
// snapshot name is same as temporary cloned image, This helps to
|
||||
// flatten the temporary cloned images as we cannot have more than 510
|
||||
// snapshots on an rbd image
|
||||
tempSnap := &rbdSnapshot{}
|
||||
tempSnap.RbdSnapName = tempClone.RbdImageName
|
||||
tempSnap.Pool = rv.Pool
|
||||
|
||||
cloneSnap := &rbdSnapshot{}
|
||||
cloneSnap.RbdSnapName = rv.RbdImageName
|
||||
cloneSnap.Pool = rv.Pool
|
||||
|
||||
cloneSnap := &rbdSnapshot{
|
||||
RbdSnapName: rv.RbdImageName,
|
||||
Pool: rv.Pool,
|
||||
}
|
||||
var (
|
||||
errClone error
|
||||
errFlatten error
|
||||
|
Reference in New Issue
Block a user