mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
cleanup: pass context to rbdImage.Destroy()
In the future we'll introduce a more standard interface for objects like Volumes and Snapshots. It is useful to have the context passed as 1st argument to all functions of those objects, including their Destroy() function. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
d5849a4801
commit
3aece2f38e
@ -335,7 +335,7 @@ func (cs *ControllerServer) CreateVolume(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rbdVol.Destroy()
|
||||
defer rbdVol.Destroy(ctx)
|
||||
// Existence and conflict checks
|
||||
if acquired := cs.VolumeLocks.TryAcquire(req.GetName()); !acquired {
|
||||
log.ErrorLog(ctx, util.VolumeOperationAlreadyExistsFmt, req.GetName())
|
||||
@ -349,10 +349,10 @@ func (cs *ControllerServer) CreateVolume(
|
||||
return nil, err
|
||||
}
|
||||
if parentVol != nil {
|
||||
defer parentVol.Destroy()
|
||||
defer parentVol.Destroy(ctx)
|
||||
}
|
||||
if rbdSnap != nil {
|
||||
defer rbdSnap.Destroy()
|
||||
defer rbdSnap.Destroy(ctx)
|
||||
}
|
||||
|
||||
err = updateTopologyConstraints(rbdVol, rbdSnap)
|
||||
@ -465,7 +465,7 @@ func flattenParentImage(
|
||||
// in case of any error call Destroy for cleanup.
|
||||
defer func() {
|
||||
if err != nil {
|
||||
rbdSnap.Destroy()
|
||||
rbdSnap.Destroy(ctx)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -661,14 +661,14 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
|
||||
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
defer rbdSnap.Destroy()
|
||||
defer rbdSnap.Destroy(ctx)
|
||||
|
||||
// update parent name(rbd image name in snapshot)
|
||||
rbdSnap.RbdImageName = rbdSnap.RbdSnapName
|
||||
parentVol := rbdSnap.toVolume()
|
||||
// as we are operating on single cluster reuse the connection
|
||||
parentVol.conn = rbdVol.conn.Copy()
|
||||
defer parentVol.Destroy()
|
||||
defer parentVol.Destroy(ctx)
|
||||
|
||||
// create clone image and delete snapshot
|
||||
err = rbdVol.cloneRbdImageFromSnapshot(ctx, rbdSnap, parentVol)
|
||||
@ -944,7 +944,7 @@ func (cs *ControllerServer) DeleteVolume(
|
||||
rbdVol, err := GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
|
||||
defer func() {
|
||||
if rbdVol != nil {
|
||||
rbdVol.Destroy()
|
||||
rbdVol.Destroy(ctx)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
@ -1094,7 +1094,7 @@ func (cs *ControllerServer) CreateSnapshot(
|
||||
rbdVol, err := GenVolFromVolID(ctx, req.GetSourceVolumeId(), cr, req.GetSecrets())
|
||||
defer func() {
|
||||
if rbdVol != nil {
|
||||
rbdVol.Destroy()
|
||||
rbdVol.Destroy(ctx)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
@ -1237,7 +1237,7 @@ func cloneFromSnapshot(
|
||||
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
defer vol.Destroy()
|
||||
defer vol.Destroy(ctx)
|
||||
|
||||
err = rbdVol.copyEncryptionConfig(ctx, &vol.rbdImage, false)
|
||||
if err != nil {
|
||||
@ -1313,7 +1313,7 @@ func (cs *ControllerServer) doSnapshotClone(
|
||||
) (*rbdVolume, error) {
|
||||
// generate cloned volume details from snapshot
|
||||
cloneRbd := rbdSnap.toVolume()
|
||||
defer cloneRbd.Destroy()
|
||||
defer cloneRbd.Destroy(ctx)
|
||||
// add image feature for cloneRbd
|
||||
f := []string{librbd.FeatureNameLayering, librbd.FeatureNameDeepFlatten}
|
||||
cloneRbd.ImageFeatureSet = librbd.FeatureSetFromNames(f)
|
||||
@ -1460,7 +1460,7 @@ func (cs *ControllerServer) DeleteSnapshot(
|
||||
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
defer rbdSnap.Destroy()
|
||||
defer rbdSnap.Destroy(ctx)
|
||||
|
||||
// safeguard against parallel create or delete requests against the same
|
||||
// name
|
||||
@ -1480,7 +1480,7 @@ func (cs *ControllerServer) DeleteSnapshot(
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
defer rbdVol.Destroy()
|
||||
defer rbdVol.Destroy(ctx)
|
||||
|
||||
rbdVol.ImageID = rbdSnap.ImageID
|
||||
// update parent name to delete the snapshot
|
||||
@ -1510,7 +1510,7 @@ func cleanUpImageAndSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, c
|
||||
if err != nil {
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
defer rbdVol.Destroy()
|
||||
defer rbdVol.Destroy(ctx)
|
||||
|
||||
err = rbdVol.openIoctx()
|
||||
if err != nil {
|
||||
@ -1584,7 +1584,7 @@ func (cs *ControllerServer) ControllerExpandVolume(
|
||||
|
||||
return nil, err
|
||||
}
|
||||
defer rbdVol.Destroy()
|
||||
defer rbdVol.Destroy(ctx)
|
||||
|
||||
// NodeExpansion is needed for PersistentVolumes with,
|
||||
// 1. Filesystem VolumeMode with & without Encryption and
|
||||
|
Reference in New Issue
Block a user