From 9b0383ce6c6b863dc260de172b580d505787d39f 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 b76187aa0..6a146d743 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -1080,7 +1080,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) } @@ -1088,25 +1088,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,