web/multinode: fix wrong free disk space in allocation on dashboard

There are many case where the keywords `free` and `available`
are confused in their usage.

For most cases, `free` space is the amount of free space left
on the whole disk, and not just in allocation while
`available` space is the amount of free space left in the
allocated disk space.

What the user/sno wants to see is not the free space but the
available space. To the SNO, free space is the free space
left in the allocated disk space.

Because of this confusion, the multinode dashboard displays
the `free` disk space instead of the free space in the
allocated disk space https://github.com/storj/storj/issues/5248
While the storagenode dashboard shows the correct free space
in the allocation.

This change fixes the wrong free disk space. I also added a
few comments to make a distinction between the `free`
and `available` fields in the `DiskSpace*` structs.

Change-Id: I11b372ca53a5ac05dc3f79834c18f85ebec11855
This commit is contained in:
Clement Sam 2023-07-05 10:22:32 +00:00 committed by Clement Sam
parent 21c1e66a85
commit 7ac2031cac
6 changed files with 27 additions and 9 deletions

View File

@ -69,7 +69,9 @@ type DiskSpace struct {
Allocated int64 `json:"allocated"`
Used int64 `json:"usedPieces"`
Trash int64 `json:"usedTrash"`
Free int64 `json:"free"`
// Free is the actual amount of free space on the whole disk, not just allocated disk space, in bytes.
Free int64 `json:"free"`
// Available is the amount of free space on the allocated disk space, in bytes.
Available int64 `json:"available"`
Overused int64 `json:"overused"`
}

View File

@ -27,7 +27,9 @@ message DiskSpaceResponse {
int64 allocated = 1;
int64 used_pieces = 2;
int64 used_trash = 3;
// Free is the actual amount of free space on the whole disk, not just allocated disk space, in bytes.
int64 free = 4;
// Available is the amount of free space on the allocated disk space, in bytes.
int64 available = 5;
int64 overused = 6;
}

View File

@ -96,7 +96,7 @@ type Blobs interface {
// when the format is already known.
StatWithStorageFormat(ctx context.Context, ref BlobRef, formatVer FormatVersion) (BlobInfo, error)
// FreeSpace return how much free space is available to the blobstore.
// FreeSpace return how much free space is left on the whole disk, not just the allocated disk space.
FreeSpace(ctx context.Context) (int64, error)
// SpaceUsedForTrash returns the total space used by the trash.
SpaceUsedForTrash(ctx context.Context) (int64, error)

View File

@ -31,12 +31,18 @@ var (
// DiskSpace consolidates monitored disk space statistics.
type DiskSpace struct {
Allocated int64
// Allocated is the amount of disk space allocated to the storage node, in bytes.
Allocated int64
// UsedForPieces is the amount of disk space used for pieces, in bytes.
UsedForPieces int64
UsedForTrash int64
Free int64
Available int64
Overused int64
// UsedForTrash is the amount of disk space used for trash, in bytes.
UsedForTrash int64
// Free is the actual amount of free space on the whole disk, not just allocated disk space, in bytes.
Free int64
// Available is the amount of free space on the allocated disk space, in bytes.
Available int64
// Overused is the amount of disk space overused by the storage node, in bytes.
Overused int64
}
// Config defines parameters for storage node disk and bandwidth usage monitoring.

View File

@ -741,6 +741,7 @@ func (store *Store) GetV0PieceInfo(ctx context.Context, satellite storj.NodeID,
// StorageStatus contains information about the disk store is using.
type StorageStatus struct {
DiskUsed int64
// DiskFree is the actual amount of free space on the whole disk, not just allocated disk space, in bytes.
DiskFree int64
}

View File

@ -19,7 +19,7 @@
<div class="disk-stat-area__info-area__item__labels-area__circle free" />
<p class="disk-stat-area__info-area__item__labels-area__label">Free</p>
</div>
<p class="disk-stat-area__info-area__item__labels-area__amount">{{ diskSpace.free | bytesToBase10String }}</p>
<p class="disk-stat-area__info-area__item__labels-area__amount">{{ freeSpace | bytesToBase10String }}</p>
</div>
<div class="disk-stat-area__info-area__item">
<div class="disk-stat-area__info-area__item__labels-area">
@ -61,7 +61,7 @@ export default class DiskStatChart extends Vue {
'',
['#D6D6D6', '#0059D0', '#8FA7C6', '#EB5757'],
[
this.diskSpace.free,
this.freeSpace,
this.diskSpace.usedPieces,
this.diskSpace.usedTrash,
this.diskSpace.overused,
@ -76,6 +76,13 @@ export default class DiskStatChart extends Vue {
public get diskSpace(): DiskSpace {
return this.$store.state.storage.diskSpace;
}
/**
* Returns free space in allocated disk space.
*/
public get freeSpace(): number {
return this.diskSpace.available;
}
}
</script>