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
e4d6ca4a48
commit
6064908bf7
|
|
@ -318,7 +318,19 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim
|
|||
}
|
||||
|
||||
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
|
||||
? { totalSize: primaryDisk.totalSize, totalUsed: primaryDisk.totalUsed }
|
||||
: primaryFs
|
||||
|
|
|
|||
|
|
@ -50,6 +50,22 @@ while true; do
|
|||
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"${mountpoint}\"}"
|
||||
FIRST=0
|
||||
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+="]"
|
||||
|
||||
# Use a tmp file for atomic update
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user