storagenode/console & /inspector: added recalculation of disk space info

Change-Id: Id003d031a6464ec095c31290fd6a756ead644261
This commit is contained in:
Qweder93 2020-08-02 19:21:43 +03:00
parent 88ff8829a1
commit f16cf5cccf
2 changed files with 31 additions and 5 deletions

View File

@ -182,10 +182,25 @@ func (s *Service) GetDashboardData(ctx context.Context) (_ *Dashboard, err error
return nil, SNOServiceErr.Wrap(err) return nil, SNOServiceErr.Wrap(err)
} }
data.DiskSpace = DiskSpaceInfo{ // temporary solution - in case we receive negative amount of free space we recalculate dir disk available space and recalculates used space.
Used: pieceTotal, // TODO: find real reason of negative space, garbage collector calculates trash correctly.
Available: s.allocatedDiskSpace.Int64(), if s.allocatedDiskSpace.Int64()-pieceTotal-trash < 0 {
Trash: trash, status, err := s.pieceStore.StorageStatus(ctx)
if err != nil {
return nil, SNOServiceErr.Wrap(err)
}
data.DiskSpace = DiskSpaceInfo{
Used: s.allocatedDiskSpace.Int64() - status.DiskFree - trash,
Available: s.allocatedDiskSpace.Int64(),
Trash: trash,
}
} else {
data.DiskSpace = DiskSpaceInfo{
Used: pieceTotal,
Available: s.allocatedDiskSpace.Int64(),
Trash: trash,
}
} }
data.Bandwidth = BandwidthInfo{ data.Bandwidth = BandwidthInfo{

View File

@ -89,10 +89,21 @@ func (inspector *Endpoint) retrieveStats(ctx context.Context) (_ *pb.StatSummary
egress := usage.Get + usage.GetAudit + usage.GetRepair egress := usage.Get + usage.GetAudit + usage.GetRepair
totalUsedBandwidth := usage.Total() totalUsedBandwidth := usage.Total()
availableSpace := inspector.pieceStoreConfig.AllocatedDiskSpace.Int64() - piecesContentSize
// temporary solution: in case we receive negative amount of free space we recalculate dir disk available space.
// TODO: find real reason of negative space, garbage collector calculates trash correctly.
if availableSpace < 0 {
status, err := inspector.pieceStore.StorageStatus(ctx)
if err != nil {
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
}
availableSpace = status.DiskFree
}
return &pb.StatSummaryResponse{ return &pb.StatSummaryResponse{
UsedSpace: piecesContentSize, UsedSpace: piecesContentSize,
AvailableSpace: inspector.pieceStoreConfig.AllocatedDiskSpace.Int64() - piecesContentSize, AvailableSpace: availableSpace,
UsedIngress: ingress, UsedIngress: ingress,
UsedEgress: egress, UsedEgress: egress,
UsedBandwidth: totalUsedBandwidth, UsedBandwidth: totalUsedBandwidth,