From 8d5e1aad4e97269ddffe7c0c01a123f7cfa93b37 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 5 Jul 2024 08:46:09 +0200 Subject: [PATCH] rbd: rename `deleteImage()` to `Delete()` Renaming the `Delete()` function makes it easier to implement the upcoming `Volume` interface. Signed-off-by: Niels de Vos --- internal/rbd/clone.go | 2 +- internal/rbd/controllerserver.go | 12 ++++++------ internal/rbd/migration.go | 2 +- internal/rbd/rbd_util.go | 6 +++--- internal/rbd/snapshot.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/rbd/clone.go b/internal/rbd/clone.go index d4312b012..25452921a 100644 --- a/internal/rbd/clone.go +++ b/internal/rbd/clone.go @@ -141,7 +141,7 @@ func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVol defer func() { if err != nil { log.DebugLog(ctx, "Removing clone image %q", rv) - errDefer := rv.deleteImage(ctx) + errDefer := rv.Delete(ctx) if errDefer != nil { log.ErrorLog(ctx, "failed to delete clone image %q: %v", rv, errDefer) } diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 12f7d709e..640827796 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -403,7 +403,7 @@ func (cs *ControllerServer) CreateVolume( metadata := k8s.GetVolumeMetadata(req.GetParameters()) err = rbdVol.setAllMetadata(metadata) if err != nil { - if deleteErr := rbdVol.deleteImage(ctx); deleteErr != nil { + if deleteErr := rbdVol.Delete(ctx); deleteErr != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, deleteErr) } @@ -621,7 +621,7 @@ func checkFlatten(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) if errors.Is(err, ErrFlattenInProgress) { return status.Error(codes.Aborted, err.Error()) } - if errDefer := rbdVol.deleteImage(ctx); errDefer != nil { + if errDefer := rbdVol.Delete(ctx); errDefer != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, errDefer) return status.Error(codes.Internal, err.Error()) @@ -681,7 +681,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot( defer func() { if err != nil { log.DebugLog(ctx, "Removing clone image %q", rbdVol) - errDefer := rbdVol.deleteImage(ctx) + errDefer := rbdVol.Delete(ctx) if errDefer != nil { log.ErrorLog(ctx, "failed to delete clone image %q: %v", rbdVol, errDefer) } @@ -764,7 +764,7 @@ func (cs *ControllerServer) createBackingImage( defer func() { if err != nil { - if deleteErr := rbdVol.deleteImage(ctx); deleteErr != nil { + if deleteErr := rbdVol.Delete(ctx); deleteErr != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, deleteErr) } } @@ -1029,7 +1029,7 @@ func cleanupRBDImage(ctx context.Context, // Deleting rbd image log.DebugLog(ctx, "deleting image %s", rbdVol.RbdImageName) - if err = rbdVol.deleteImage(ctx); err != nil { + if err = rbdVol.Delete(ctx); err != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, err) @@ -1188,7 +1188,7 @@ func (cs *ControllerServer) CreateSnapshot( defer func() { if err != nil { log.DebugLog(ctx, "Removing clone image %q", rbdVol) - errDefer := rbdVol.deleteImage(ctx) + errDefer := rbdVol.Delete(ctx) if errDefer != nil { log.ErrorLog(ctx, "failed to delete clone image %q: %v", rbdVol, errDefer) } diff --git a/internal/rbd/migration.go b/internal/rbd/migration.go index 089a95139..b7629251b 100644 --- a/internal/rbd/migration.go +++ b/internal/rbd/migration.go @@ -82,7 +82,7 @@ func deleteMigratedVolume(ctx context.Context, parsedMigHandle *migrationVolID, return err } defer rv.Destroy(ctx) - err = rv.deleteImage(ctx) + err = rv.Delete(ctx) if err != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s, err: %v", rv, err) } diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index c3f44e2dd..c1135226b 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -627,8 +627,8 @@ func (ri *rbdImage) ensureImageCleanup(ctx context.Context) error { return nil } -// deleteImage deletes a ceph image with provision and volume options. -func (ri *rbdImage) deleteImage(ctx context.Context) error { +// Delete deletes a ceph image with provision and volume options. +func (ri *rbdImage) Delete(ctx context.Context) error { image := ri.RbdImageName log.DebugLog(ctx, "rbd: delete %s using mon %s, pool %s", image, ri.Monitors, ri.Pool) @@ -706,7 +706,7 @@ func (ri *rbdImage) trashRemoveImage(ctx context.Context) error { // DeleteTempImage deletes the temporary image created for volume datasource. func (rv *rbdVolume) DeleteTempImage(ctx context.Context) error { tempClone := rv.generateTempClone() - err := tempClone.deleteImage(ctx) + err := tempClone.Delete(ctx) if err != nil { if errors.Is(err, ErrImageNotFound) { return tempClone.ensureImageCleanup(ctx) diff --git a/internal/rbd/snapshot.go b/internal/rbd/snapshot.go index d6dcd48c2..fc3fa2427 100644 --- a/internal/rbd/snapshot.go +++ b/internal/rbd/snapshot.go @@ -56,7 +56,7 @@ func createRBDClone( errSnap := parentVol.deleteSnapshot(ctx, snap) if errSnap != nil { log.ErrorLog(ctx, "failed to delete snapshot: %v", errSnap) - delErr := cloneRbdVol.deleteImage(ctx) + delErr := cloneRbdVol.Delete(ctx) if delErr != nil { log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", cloneRbdVol, delErr) } @@ -85,7 +85,7 @@ func cleanUpSnapshot( } if rbdVol != nil { - err := rbdVol.deleteImage(ctx) + err := rbdVol.Delete(ctx) if err != nil { if !errors.Is(err, ErrImageNotFound) { log.ErrorLog(ctx, "failed to delete rbd image %q with error: %v", rbdVol, err)