Skip to content

PulpStatus - fix storage gauge when the backend reports no capacity - #346

Open
warisshaikh1 wants to merge 1 commit into
pulp:mainfrom
warisshaikh1:fix-storage-gauge-object-storage
Open

PulpStatus - fix storage gauge when the backend reports no capacity#346
warisshaikh1 wants to merge 1 commit into
pulp:mainfrom
warisshaikh1:fix-storage-gauge-object-storage

Conversation

@warisshaikh1

Copy link
Copy Markdown

Problem

On any install that keeps artifacts in object storage, the Status page reports storage as a red, 100%-full gauge with Total: 0 bytes and Free: 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

null here is the documented API contract, not an error. _disk_usage() in pulpcore/app/views/status.py only measures real capacity for filesystem storage:

def _disk_usage():
    domain = get_domain()
    if domain.storage_class == "pulpcore.app.models.storage.FileSystem":
        storage = domain.get_storage()
        try:
            return shutil.disk_usage(storage.location)
        except Exception:
            _logger.exception(_("Failed to determine disk usage"))
    else:
        used = Artifact.objects.filter(pulp_domain=domain).aggregate(size=Sum("size", default=0))
        return StorageSpace(None, used["size"], None)

An object store has no capacity to measure, so total and free are None — and StorageSerializer declares both allow_null=True.

StatusStorage doesn't handle that:

  • (100 / null) * usednull coerces to 0Infinity. Progress clamps that to a full bar, and the variant ladder reads Infinity > 88 as danger, hence red and full.
  • getHumanSize(null)parseInt(null, 10) || 00"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 returns None, so storage itself is null. storage.total then throws a TypeError that 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 reported rather than as zero. The filesystem case is untouched.

status.storage before after
{total: null, used: 188976272, free: null} Infinity, variant=danger, Total: 0 bytes, Free: 0 bytes gauge hidden, Total: Not reported, Used: 180 MiB, Free: Not reported
{total: 107374182400, used: 53687091200, free: 53687091200} 50% 50% (unchanged)
null TypeError — blank page gauge hidden, all three Not reported

I 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.md entry, 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 — clean
  • npm run build — succeeds (only the pre-existing bundle-size warnings)
  • Verified against a live pulpcore 3.116.0 on Ceph RGW, and against the filesystem and null payload shapes above

Happy to adjust the Not reported wording, or to show a plain "Used: X" line without the labels for the unmeasured case, if maintainers prefer.

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.
@warisshaikh1

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant