PulpStatus - fix storage gauge when the backend reports no capacity - #346
Open
warisshaikh1 wants to merge 1 commit into
Open
PulpStatus - fix storage gauge when the backend reports no capacity#346warisshaikh1 wants to merge 1 commit into
warisshaikh1 wants to merge 1 commit into
Conversation
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.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On any install that keeps artifacts in object storage, the Status page reports storage as a red, 100%-full gauge with
Total: 0 bytesandFree: 0 bytes— regardless of how little is actually stored.Reproduced on pulpcore 3.116.0 with a Ceph RGW (S3) backend.
/pulp/api/v3/status/returns:{ "storage": { "total": null, "used": 188976272, "free": null } }Cause
nullhere is the documented API contract, not an error._disk_usage()inpulpcore/app/views/status.pyonly measures real capacity for filesystem storage:An object store has no capacity to measure, so
totalandfreeareNone— andStorageSerializerdeclares bothallow_null=True.StatusStoragedoesn't handle that:(100 / null) * used→nullcoerces to0→Infinity.Progressclamps that to a full bar, and the variant ladder readsInfinity > 88asdanger, hence red and full.getHumanSize(null)→parseInt(null, 10) || 0→0→"0 bytes"for both Total and Free.There's a second, related problem on the filesystem path: if
shutil.disk_usage()raises,_disk_usage()falls through and returnsNone, sostorageitself isnull.storage.totalthen throws aTypeErrorthat blanks the entire Status page.Fix
Draw the gauge only when there is a capacity to draw a percentage against, and report unmeasured fields as
Not reportedrather than as zero. The filesystem case is untouched.status.storage{total: null, used: 188976272, free: null}Infinity,variant=danger,Total: 0 bytes,Free: 0 bytesTotal: Not reported,Used: 180 MiB,Free: Not reported{total: 107374182400, used: 53687091200, free: 53687091200}50%50%(unchanged)nullTypeError— blank pageNot reportedI deliberately left
getHumanSize()alone: it's shared with the execution-environment views, which pass real numbers, so distinguishing "unmeasured" from "zero" belongs at this call site rather than in the shared helper.No
CHANGES.mdentry, since that file is generated from PR titles by the release workflow.Testing
npm run lint:js,npm run lint:ts,npm run lint:ls— cleannpm run build— succeeds (only the pre-existing bundle-size warnings)nullpayload shapes aboveHappy to adjust the
Not reportedwording, or to show a plain "Used: X" line without the labels for the unmeasured case, if maintainers prefer.