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
@ -385,7 +385,7 @@ func (ri *rbdImage) Connect(cr *util.Credentials) error {
|
||||
|
||||
// Destroy cleans up the rbdVolume and closes the connection to the Ceph
|
||||
// cluster in case one was setup.
|
||||
func (ri *rbdImage) Destroy() {
|
||||
func (ri *rbdImage) Destroy(ctx context.Context) {
|
||||
if ri.ioctx != nil {
|
||||
ri.ioctx.Destroy()
|
||||
}
|
||||
@ -777,7 +777,7 @@ func flattenClonedRbdImages(
|
||||
rv.Pool = pool
|
||||
rv.RbdImageName = rbdImageName
|
||||
|
||||
defer rv.Destroy()
|
||||
defer rv.Destroy(ctx)
|
||||
err := rv.Connect(cr)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to open connection %s; err %v", rv, err)
|
||||
@ -1045,7 +1045,7 @@ func genSnapFromSnapID(
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
rbdSnap.Destroy()
|
||||
rbdSnap.Destroy(ctx)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -1064,7 +1064,7 @@ func genSnapFromSnapID(
|
||||
}
|
||||
}
|
||||
|
||||
err = updateSnapshotDetails(rbdSnap)
|
||||
err = updateSnapshotDetails(ctx, rbdSnap)
|
||||
if err != nil {
|
||||
return rbdSnap, fmt.Errorf("failed to update snapshot details for %q: %w", rbdSnap, err)
|
||||
}
|
||||
@ -1074,13 +1074,13 @@ func genSnapFromSnapID(
|
||||
|
||||
// updateSnapshotDetails will copy the details from the rbdVolume to the
|
||||
// rbdSnapshot. example copying size from rbdVolume to rbdSnapshot.
|
||||
func updateSnapshotDetails(rbdSnap *rbdSnapshot) error {
|
||||
func updateSnapshotDetails(ctx context.Context, rbdSnap *rbdSnapshot) error {
|
||||
vol := rbdSnap.toVolume()
|
||||
err := vol.Connect(rbdSnap.conn.Creds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer vol.Destroy()
|
||||
defer vol.Destroy(ctx)
|
||||
|
||||
err = vol.getImageInfo()
|
||||
if err != nil {
|
||||
@ -1685,7 +1685,7 @@ func (ri *rbdImage) flattenParent(ctx context.Context, hardLimit, softLimit uint
|
||||
if parentImage == nil {
|
||||
return nil
|
||||
}
|
||||
defer parentImage.Destroy()
|
||||
defer parentImage.Destroy(ctx)
|
||||
|
||||
return parentImage.flattenRbdImage(ctx, false, hardLimit, softLimit)
|
||||
}
|
||||
@ -2128,7 +2128,7 @@ func genVolFromVolIDWithMigration(
|
||||
}
|
||||
rv, err := GenVolFromVolID(ctx, volID, cr, secrets)
|
||||
if err != nil {
|
||||
rv.Destroy()
|
||||
rv.Destroy(ctx)
|
||||
}
|
||||
|
||||
return rv, err
|
||||
|
Reference in New Issue
Block a user