mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
fix: prefer real block devices over tmpfs for storage display
The disk-collector could produce an empty fsSize array when /host/proc/1/mounts is unreadable, causing the admin UI to fall back to systeminformation's fsSize which includes tmpfs mounts. This led to the storage display showing ~1.5 GB (tmpfs /run) instead of the actual storage capacity. Two changes: - disk-collector: fall back to df on /storage when host mount table yields no real filesystems, since /storage is always bind-mounted from the host and reflects the actual backing device. - easy-setup UI: when falling back to systeminformation fsSize, filter for /dev/ block devices and prefer the largest one instead of blindly taking the first entry. Fixes #373
This commit is contained in:
parent
c0b1980bbc
commit
d53ccd2dc8
|
|
@ -318,7 +318,19 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryDisk = getPrimaryDisk()
|
const primaryDisk = getPrimaryDisk()
|
||||||
const primaryFs = systemInfo?.fsSize?.[0]
|
// When falling back to fsSize (systeminformation), prefer real block devices
|
||||||
|
// over virtual filesystems like tmpfs which report misleading capacity.
|
||||||
|
const getPrimaryFs = () => {
|
||||||
|
if (!systemInfo?.fsSize || systemInfo.fsSize.length === 0) return null
|
||||||
|
const realDevices = systemInfo.fsSize.filter((fs) => fs.fs.startsWith('/dev/'))
|
||||||
|
if (realDevices.length > 0) {
|
||||||
|
return realDevices.reduce((largest, current) =>
|
||||||
|
current.size > largest.size ? current : largest
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return systemInfo.fsSize[0]
|
||||||
|
}
|
||||||
|
const primaryFs = getPrimaryFs()
|
||||||
const storageInfo = primaryDisk
|
const storageInfo = primaryDisk
|
||||||
? { totalSize: primaryDisk.totalSize, totalUsed: primaryDisk.totalUsed }
|
? { totalSize: primaryDisk.totalSize, totalUsed: primaryDisk.totalUsed }
|
||||||
: primaryFs
|
: primaryFs
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,22 @@ while true; do
|
||||||
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"${mountpoint}\"}"
|
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"${mountpoint}\"}"
|
||||||
FIRST=0
|
FIRST=0
|
||||||
done < /host/proc/1/mounts
|
done < /host/proc/1/mounts
|
||||||
|
|
||||||
|
# Fallback: if no real filesystems were found from the host mount table
|
||||||
|
# (e.g. /host/proc/1/mounts was unreadable), try the /storage mount directly.
|
||||||
|
# The disk-collector container always has /storage bind-mounted from the host,
|
||||||
|
# so df on /storage reflects the actual backing device and its capacity.
|
||||||
|
if [[ "$FIRST" -eq 1 ]] && mountpoint -q /storage 2>/dev/null; then
|
||||||
|
STATS=$(df -B1 /storage 2>/dev/null | awk 'NR==2{print $1,$2,$3,$4,$5}')
|
||||||
|
if [[ -n "$STATS" ]]; then
|
||||||
|
read -r dev size used avail pct <<< "$STATS"
|
||||||
|
pct="${pct/\%/}"
|
||||||
|
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"/storage\"}"
|
||||||
|
FIRST=0
|
||||||
|
log "Used /storage mount as fallback for filesystem info."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
FS_JSON+="]"
|
FS_JSON+="]"
|
||||||
|
|
||||||
# Use a tmp file for atomic update
|
# Use a tmp file for atomic update
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user