Skip to content

Commit

Permalink
lxd/storage: Get volume total size regardless of driver
Browse files Browse the repository at this point in the history
When driver does not support getting the volume usage, we are returning prematurely and not getting the volume total size, even when it is possible.

Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Nov 22, 2024
1 parent 7e62ce7 commit f149e2c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lxd/storage/backend_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3261,12 +3261,14 @@ func (b *lxdBackend) GetInstanceUsage(inst instance.Instance) (*VolumeUsage, err
volStorageName := project.Instance(inst.Project().Name, inst.Name())
vol := b.GetVolume(volType, contentType, volStorageName, dbVol.Config)

// Get the usage.
// Get the usage
// If storage driver does not support getting the volume usage, proceed getting the total.
size, err := b.driver.GetVolumeUsage(vol)
if err != nil {
if err != nil && !errors.Is(err, drivers.ErrNotSupported) {
return nil, err
}

// If driver does not support getting volume usage, this value would be -1.
val.Used = size

// Get the total size.
Expand Down

0 comments on commit f149e2c

Please sign in to comment.