Skip to content

Commit c55f825

Browse files
committed
fix: misleading disk space indicator for shared ZFS pools (#674)
1 parent 0ea3188 commit c55f825

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • ui/packages/shared/pages/Instance/Info/Disks/Disk

ui/packages/shared/pages/Instance/Info/Disks/Disk/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,14 @@ const getPercent = (value: number, total: number) =>
8484
export const Disk = (props: Props) => {
8585
const classes = useStyles()
8686

87+
// pool-level used space: in shared ZFS pools, usedDataSize reflects only the
88+
// dataset, while freeDataSize reflects the entire pool, so we derive the
89+
// actual pool usage from totalDataSize - freeDataSize.
90+
const usedPoolSize = Math.max(0, props.totalDataSize - props.freeDataSize)
91+
8792
const shouldShowWarning =
8893
props.status === 'active' &&
89-
getPercent(props.usedDataSize, props.totalDataSize) >
90-
WARNING_THRESHOLD_PERCENT
94+
getPercent(usedPoolSize, props.totalDataSize) > WARNING_THRESHOLD_PERCENT
9195

9296
return (
9397
<div className={classes.root}>
@@ -154,7 +158,7 @@ export const Disk = (props: Props) => {
154158
</div>
155159

156160
<ProgressBar
157-
value={props.usedDataSize}
161+
value={usedPoolSize}
158162
total={props.totalDataSize}
159163
thresholdPercent={WARNING_THRESHOLD_PERCENT}
160164
/>

0 commit comments

Comments
 (0)