Skip to content

Commit

Permalink
cleanup: remove unneeded updateSnapshotDetails() function
Browse files Browse the repository at this point in the history
`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 <[email protected]>
  • Loading branch information
nixpanic committed Sep 16, 2024
1 parent 8de667a commit 414118a
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,33 +1068,14 @@ 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)
}

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,
Expand Down

0 comments on commit 414118a

Please sign in to comment.