From 414118ababc5e126c5514fb64beb200ec3942a98 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 16 Sep 2024 14:30:24 +0200 Subject: [PATCH] cleanup: remove unneeded `updateSnapshotDetails()` function `updateSnapshotDetails()` just calls `getImageInfo()` on an `rbdVolume` created from the `rbdSnapshot`. `getImageInfo()` is a function of the base `rbdImage` struct, so there really is no need for this indirection. Signed-off-by: Niels de Vos --- internal/rbd/rbd_util.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 703809c953e..35631c8492e 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -1068,7 +1068,7 @@ func genSnapFromSnapID( } } - err = updateSnapshotDetails(ctx, rbdSnap) + err = rbdSnap.getImageInfo() if err != nil { return rbdSnap, fmt.Errorf("failed to update snapshot details for %q: %w", rbdSnap, err) } @@ -1076,25 +1076,6 @@ func genSnapFromSnapID( return rbdSnap, err } -// updateSnapshotDetails will copy the details from the rbdVolume to the -// rbdSnapshot. example copying size from rbdVolume to rbdSnapshot. -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(ctx) - - err = vol.getImageInfo() - if err != nil { - return err - } - rbdSnap.VolSize = vol.VolSize - - return nil -} - // generateVolumeFromVolumeID generates a rbdVolume structure from the provided identifier. func generateVolumeFromVolumeID( ctx context.Context,