From 3f63a63a7c02479a10df8efeb3924240676601e1 Mon Sep 17 00:00:00 2001 From: warisshaikh1 Date: Fri, 28 Aug 2026 13:42:54 -0400 Subject: [PATCH] PulpStatus - fix storage gauge when the backend reports no capacity pulpcore only measures total and free space when artifacts live on a filesystem. For every other backend _disk_usage() returns StorageSpace(None, used, None), and both serializer fields are declared allow_null=True, so null is part of the API contract rather than an error. StatusStorage did not handle it. `(100 / null) * used` is Infinity, which Progress clamps to a full bar and which the variant ladder reads as `> 88`, so every S3/Azure/Ceph install was shown as a red, 100%-full gauge. getHumanSize(null) coerces to 0, so Total and Free both read "0 bytes" beside it -- an install with 180 MiB of artifacts reported itself out of space. Hide the gauge when there is no capacity to draw a percentage against and report the unmeasured fields as "Not reported", leaving the filesystem case exactly as it was. Also stop assuming `storage` is present at all: _disk_usage() returns None if shutil.disk_usage() raises, and reading .total off that threw a TypeError that blanked the whole Status page. --- src/containers/pulp-status.tsx | 68 +++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/containers/pulp-status.tsx b/src/containers/pulp-status.tsx index 34db6bd4..f005ca78 100644 --- a/src/containers/pulp-status.tsx +++ b/src/containers/pulp-status.tsx @@ -132,33 +132,57 @@ const StatusRedisConnection = ({ redisConnection: { connected: boolean }; }) => (redisConnection?.connected ? t`Connected` : `Not connected`); -const StatusStorage = ({ storage }: { storage: { total; used; free } }) => { - const value = (100 / storage.total) * storage.used; - const total = getHumanSize(storage.total); - const used = getHumanSize(storage.used); - const free = getHumanSize(storage.free); +// pulpcore measures total and free space only when artifacts live on a +// filesystem. Every other backend reports both as null -- an object store has no +// capacity to measure -- and `storage` itself is null if the filesystem lookup +// raises. See _disk_usage() in pulpcore/app/views/status.py; the corresponding +// serializer fields are allow_null=True. +const isMeasured = (value): value is number => + typeof value === 'number' && Number.isFinite(value); + +const StatusStorage = ({ + storage, +}: { + storage?: { total?: number; used?: number; free?: number }; +}) => { + const { total, used, free } = storage ?? {}; + + // Only a real capacity makes a percentage meaningful. Without this guard + // `(100 / null) * used` is Infinity, which Progress clamps to a full red bar, + // reporting every object-storage install as out of space. + const percentage = + isMeasured(total) && total > 0 && isMeasured(used) + ? (100 / total) * used + : null; + + const size = (value) => + isMeasured(value) ? getHumanSize(value) : t`Not reported`; return ( <> - 88 - ? 'danger' - : value > 66 - ? 'warning' - : value > 33 - ? null - : 'success' - } - /> -
- {t`Total`}: {total} + {percentage === null ? null : ( + <> + 88 + ? 'danger' + : percentage > 66 + ? 'warning' + : percentage > 33 + ? null + : 'success' + } + /> +
+ + )} + {t`Total`}: {size(total)}
- {t`Used`}: {used} + {t`Used`}: {size(used)}
- {t`Free`}: {free} + {t`Free`}: {size(free)} ); };