Move direct volume driver interaction to store
Since the volume store already provides this functionality, we should just use it rather than duplicating it. Signed-off-by: Brian Goff <cpuguy83@gmail.com> Upstream-commit: 63826e291ba3b88443b64802084bbb3931857b56 Component: engine
This commit is contained in:
@@ -35,41 +35,39 @@ func (daemon *Daemon) SystemDiskUsage(ctx context.Context) (*types.DiskUsage, er
|
||||
return nil, fmt.Errorf("failed to retrieve image list: %v", err)
|
||||
}
|
||||
|
||||
// Get all local volumes
|
||||
allVolumes := []*types.Volume{}
|
||||
getLocalVols := func(v volume.Volume) error {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
if d, ok := v.(volume.DetailedVolume); ok {
|
||||
// skip local volumes with mount options since these could have external
|
||||
// mounted filesystems that will be slow to enumerate.
|
||||
if len(d.Options()) > 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
name := v.Name()
|
||||
refs := daemon.volumes.Refs(v)
|
||||
|
||||
tv := volumeToAPIType(v)
|
||||
sz, err := directory.Size(ctx, v.Path())
|
||||
if err != nil {
|
||||
logrus.Warnf("failed to determine size of volume %v", name)
|
||||
sz = -1
|
||||
}
|
||||
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: int64(len(refs))}
|
||||
allVolumes = append(allVolumes, tv)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
err = daemon.traverseLocalVolumes(getLocalVols)
|
||||
volumes, err := daemon.volumes.FilterByDriver(volume.DefaultDriverName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var allVolumes []*types.Volume
|
||||
for _, v := range volumes {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
default:
|
||||
}
|
||||
if d, ok := v.(volume.DetailedVolume); ok {
|
||||
if len(d.Options()) > 0 {
|
||||
// skip local volumes with mount options since these could have external
|
||||
// mounted filesystems that will be slow to enumerate.
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
name := v.Name()
|
||||
refs := daemon.volumes.Refs(v)
|
||||
|
||||
tv := volumeToAPIType(v)
|
||||
sz, err := directory.Size(ctx, v.Path())
|
||||
if err != nil {
|
||||
logrus.Warnf("failed to determine size of volume %v", name)
|
||||
sz = -1
|
||||
}
|
||||
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: int64(len(refs))}
|
||||
allVolumes = append(allVolumes, tv)
|
||||
}
|
||||
|
||||
allLayersSize, err := daemon.imageService.LayerDiskUsage(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user