Skip to content

OCPBUGS-95592: Humanize memory and storage values in ResourceQuota display - #16874

Open
ericahinkleRH wants to merge 1 commit into
openshift:mainfrom
ericahinkleRH:OCPBUGS-95592-resourcequota-memory-humanize
Open

OCPBUGS-95592: Humanize memory and storage values in ResourceQuota display#16874
ericahinkleRH wants to merge 1 commit into
openshift:mainfrom
ericahinkleRH:OCPBUGS-95592-resourcequota-memory-humanize

Conversation

@ericahinkleRH

@ericahinkleRH ericahinkleRH commented Jul 28, 2026

Copy link
Copy Markdown

Analysis / Root cause:
ResourceQuota memory and storage limits were displayed as raw bytes (e.g., "2147483648"), making them difficult for users to read and interpret at a glance.

Solution description:

  • Added isBinaryResourceType() helper to identify resource types that should be displayed as binary bytes (memory, storage, ephemeral-storage)
  • Added formatResourceValue() helper that conditionally applies humanizeBinaryBytes() formatting
  • Updated ResourceUsageRow component to use formatResourceValue() for all quota value displays
  • Values are now displayed in human-readable format (e.g., "2 GiB" instead of "2147483648")
  • Non-binary resources (CPU, pod counts, etc.) continue to display as before

Screenshots / screen recording:
Before: Memory values displayed as "2147483648"
After: Memory values displayed as "2 GiB"

(User will add screenshot showing the actual UI improvement)

Test setup:

  1. Create a ResourceQuota with memory/storage limits in a namespace
  2. Navigate to Administration → ResourceQuotas
  3. View the quota details

Test cases:

  • ✅ Memory quota values display in GiB/MiB format
  • ✅ Storage quota values display in GiB/MiB format
  • ✅ Ephemeral storage values display in GiB/MiB format
  • ✅ CPU and count-based quotas display unchanged
  • ✅ Unit tests pass for humanized values

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Summary by CodeRabbit

  • Enhancements
    • Resource quota values for memory and storage (including binary resource types) are now displayed in human-readable GiB format.
    • Used, total used (ACRQ), and maximum capacity fields are formatted consistently within each quota row.
    • When quota values are missing or null/undefined, the UI now shows a dash instead of leaving cells blank or showing raw data.
  • Tests
    • Added tests to confirm ResourceUsageRow renders the expected GiB outputs for memory and storage quota values.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8c04c8a6-26e6-4d5f-a0d7-7d6d0c8d1d1b

📥 Commits

Reviewing files that changed from the base of the PR and between ec68b31 and 2359c76.

📒 Files selected for processing (2)
  • frontend/public/components/__tests__/resource-quota.spec.tsx
  • frontend/public/components/resource-quota.jsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/public/components/tests/resource-quota.spec.tsx
  • frontend/public/components/resource-quota.jsx

Walkthrough

Resource quota table values are humanized for memory and storage resources, missing values render as DASH, and tests verify GiB output for usage and limits.

Changes

Resource quota formatting

Layer / File(s) Summary
Binary resource formatting
frontend/public/components/resource-quota.jsx
Binary resource values are humanized, while null and undefined values render as DASH.
Quota rendering and validation
frontend/public/components/resource-quota.jsx, frontend/public/components/__tests__/resource-quota.spec.tsx
Formatted values are applied to ACRQ and standard quota cells, with tests covering GiB output for memory and storage usage and limits.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: rhamilto, leo6leo

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific, concise, and accurately summarizes the ResourceQuota humanization change.
Description check ✅ Passed The description includes the required root cause, solution, tests, screenshots, and other template sections, with only minor gaps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed New resource-quota tests use static titles only; no interpolated names, random IDs, timestamps, or other dynamic data appear in the test names.
Test Structure And Quality ✅ Passed These are isolated RTL component tests, not Ginkgo; they don’t touch cluster resources or waits, and each new it block checks one humanization behavior.
Microshift Test Compatibility ✅ Passed Only React unit tests were added; no Ginkgo e2e tests, MicroShift guards, or unsupported OpenShift API references appear.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only a React unit test in frontend/public/components/tests; no Ginkgo e2e test or multi-node assumption was added.
Topology-Aware Scheduling Compatibility ✅ Passed Only frontend quota rendering/tests changed; no manifests, operators, controllers, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed PR only changes frontend React files; no process-level setup or stdout logging was added, and no stdout-related patterns were found.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS: The PR only adds frontend unit tests and local component formatting; no Ginkgo e2e, IP literals, host/IP parsing, or external connectivity are introduced.
No-Weak-Crypto ✅ Passed No weak crypto, custom crypto, or secret comparisons were added; changes only format quota byte values and add UI tests.
Container-Privileges ✅ Passed Only frontend quota component/test files changed; no k8s manifests or privileged settings (privileged/hostPID/etc.) were added.
No-Sensitive-Data-In-Logs ✅ Passed No logging statements or sensitive-data output were added in the changed files; the PR only formats quota values and adds tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
frontend/public/components/__tests__/resource-quota.spec.tsx (1)

193-243: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the ACRQ formatting path.

These tests exercise only ResourceQuota. Add an AppliedClusterResourceQuota fixture that verifies humanized namespace usage, total usage, and max values in the branch changed at Lines 209-211. Include missing and zero values to lock down the intended DASH versus 0 behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/public/components/__tests__/resource-quota.spec.tsx` around lines
193 - 243, Add an AppliedClusterResourceQuota fixture and test alongside the
existing ResourceQuota cases in the ResourceUsageRow suite. Exercise the ACRQ
formatting branch to verify humanized namespace usage, total usage, and maximum
values, including missing values rendering as DASH and zero values rendering as
0.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/public/components/resource-quota.jsx`:
- Around line 94-99: Update formatResourceValue so numeric zero is preserved
rather than converted to DASH. Replace the broad falsy check with an explicit
check for undefined, null, or an empty string, while leaving binary-resource
formatting and other values unchanged.
- Around line 85-91: Update isBinaryResourceType to use an allowlist of explicit
binary quota resource keys, rather than substring checks for “memory” or
“storage.” Ensure only the known byte-based keys are classified as binary, while
count-based keys such as storageclass quota resources remain non-binary.

---

Nitpick comments:
In `@frontend/public/components/__tests__/resource-quota.spec.tsx`:
- Around line 193-243: Add an AppliedClusterResourceQuota fixture and test
alongside the existing ResourceQuota cases in the ResourceUsageRow suite.
Exercise the ACRQ formatting branch to verify humanized namespace usage, total
usage, and maximum values, including missing values rendering as DASH and zero
values rendering as 0.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 81e7512e-02a4-4d26-804f-a560a256f341

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf961a and 662c99f.

📒 Files selected for processing (2)
  • frontend/public/components/__tests__/resource-quota.spec.tsx
  • frontend/public/components/resource-quota.jsx

Comment on lines +85 to +91
const isBinaryResourceType = (resourceType) => {
// Resource types that should be displayed as binary bytes (e.g., GiB, MiB)
return (
resourceType.includes('memory') ||
resourceType.includes('storage') ||
resourceType.includes('ephemeral-storage')
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the file and inspect the relevant section with line numbers.
git ls-files 'frontend/public/components/resource-quota.jsx'
wc -l frontend/public/components/resource-quota.jsx
sed -n '1,180p' frontend/public/components/resource-quota.jsx | cat -n

# Find where the helper is used and any related quota formatting logic.
rg -n "isBinaryResourceType|humanize|resourceType" frontend/public/components frontend -g '!**/node_modules/**'

Repository: openshift/console

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the resource quota tests around memory/storage handling.
sed -n '180,260p' frontend/public/components/__tests__/resource-quota.spec.tsx | cat -n

# Inspect the byte humanization helper to understand what happens to count values.
sed -n '330,430p' frontend/public/components/utils/units.js | cat -n

# Look for any resource quota keys that contain "storage" but are not byte quantities.
rg -n "\bstorage\b|storageclass\.storage\.k8s\.io|ephemeral-storage" frontend/public/components frontend/e2e -g '!**/node_modules/**'

Repository: openshift/console

Length of output: 17646


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the humanization functions used by resource-quota.jsx.
sed -n '140,230p' frontend/public/components/utils/units.js | cat -n

# Check the Kubernetes quota docs mention the storage-class-specific PVC quota key.
python3 - <<'PY'
import urllib.request, re
url = "https://kubernetes.io/docs/concepts/policy/resource-quotas/"
html = urllib.request.urlopen(url, timeout=20).read().decode("utf-8", "replace")
for pat in [
    r"storageclass\.storage\.k8s\.io/persistentvolumeclaims",
    r"<storage-class-name>\.storageclass\.storage\.k8s\.io/persistentvolumeclaims",
]:
    m = re.search(pat, html)
    print(pat, "=>", bool(m))
PY

Repository: openshift/console

Length of output: 5826


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the remaining unit-conversion internals.
sed -n '1,140p' frontend/public/components/utils/units.js | cat -n
sed -n '140,260p' frontend/public/components/utils/units.js | cat -n

# Search for resource-quota tests that exercise non-byte quota keys.
rg -n "persistentvolumeclaims|pods|services|configmaps|secrets|count/" frontend/public/components/__tests__/resource-quota.spec.tsx frontend/public/components/resource-quota.jsx frontend/public/components -g '!**/node_modules/**'

Repository: openshift/console

Length of output: 29271


Match only explicit binary quota keys. includes('storage') also matches count-based keys like storageclass.storage.k8s.io/persistentvolumeclaims, so their values get byte formatting. Use an allowlist of the known byte-based resource keys instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/public/components/resource-quota.jsx` around lines 85 - 91, Update
isBinaryResourceType to use an allowlist of explicit binary quota resource keys,
rather than substring checks for “memory” or “storage.” Ensure only the known
byte-based keys are classified as binary, while count-based keys such as
storageclass quota resources remain non-binary.

Source: MCP tools

Comment on lines +94 to +99
const formatResourceValue = (value, resourceType) => {
if (!value) {
return DASH;
}
return isBinaryResourceType(resourceType) ? humanizeBinaryBytes(value).string : value;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve numeric zero values.

!value converts a legitimate 0 usage into DASH. The existing ACRQ fixture supplies numeric zero at Line 156 and expects 0 at Line 183, so this change causes that rendering/test to fail. Check explicitly for undefined, null, or an empty string instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/public/components/resource-quota.jsx` around lines 94 - 99, Update
formatResourceValue so numeric zero is preserved rather than converted to DASH.
Replace the broad falsy check with an explicit check for undefined, null, or an
empty string, while leaving binary-resource formatting and other values
unchanged.

@openshift-ci
openshift-ci Bot requested review from Leo6Leo and rhamilto July 28, 2026 16:31
@openshift-ci openshift-ci Bot added the component/core Related to console core functionality label Jul 28, 2026
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ericahinkleRH
Once this PR has been reviewed and has the lgtm label, please assign vojtechszocs for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jul 28, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ericahinkleRH: This pull request references Jira Issue OCPBUGS-95592, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Analysis / Root cause:
ResourceQuota memory and storage limits were displayed as raw bytes (e.g., "2147483648"), making them difficult for users to read and interpret at a glance.

Solution description:

  • Added isBinaryResourceType() helper to identify resource types that should be displayed as binary bytes (memory, storage, ephemeral-storage)
  • Added formatResourceValue() helper that conditionally applies humanizeBinaryBytes() formatting
  • Updated ResourceUsageRow component to use formatResourceValue() for all quota value displays
  • Values are now displayed in human-readable format (e.g., "2 GiB" instead of "2147483648")
  • Non-binary resources (CPU, pod counts, etc.) continue to display as before

Screenshots / screen recording:
Before: Memory values displayed as "2147483648"
After: Memory values displayed as "2 GiB"

(User will add screenshot showing the actual UI improvement)

Test setup:

  1. Create a ResourceQuota with memory/storage limits in a namespace
  2. Navigate to Administration → ResourceQuotas
  3. View the quota details

Test cases:

  • ✅ Memory quota values display in GiB/MiB format
  • ✅ Storage quota values display in GiB/MiB format
  • ✅ Ephemeral storage values display in GiB/MiB format
  • ✅ CPU and count-based quotas display unchanged
  • ✅ Unit tests pass for humanized values

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Summary by CodeRabbit

  • Enhancements
  • Resource quota values for memory and storage are now shown in a human-readable GiB format.
  • Used, total used (ACRQ), and maximum capacity fields are formatted consistently.
  • When quota values are empty or unavailable, the UI displays a dash instead of a raw or blank value.
  • Tests
  • Added validation ensuring memory and storage quotas render the expected human-readable GiB output.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@ericahinkleRH
ericahinkleRH force-pushed the OCPBUGS-95592-resourcequota-memory-humanize branch from a2b96d5 to ec68b31 Compare July 28, 2026 16:59
@ericahinkleRH

Copy link
Copy Markdown
Author

/test pull-ci-openshift-console-main-frontend

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@ericahinkleRH: This pull request references Jira Issue OCPBUGS-95592, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Analysis / Root cause:
ResourceQuota memory and storage limits were displayed as raw bytes (e.g., "2147483648"), making them difficult for users to read and interpret at a glance.

Solution description:

  • Added isBinaryResourceType() helper to identify resource types that should be displayed as binary bytes (memory, storage, ephemeral-storage)
  • Added formatResourceValue() helper that conditionally applies humanizeBinaryBytes() formatting
  • Updated ResourceUsageRow component to use formatResourceValue() for all quota value displays
  • Values are now displayed in human-readable format (e.g., "2 GiB" instead of "2147483648")
  • Non-binary resources (CPU, pod counts, etc.) continue to display as before

Screenshots / screen recording:
Before: Memory values displayed as "2147483648"
After: Memory values displayed as "2 GiB"

(User will add screenshot showing the actual UI improvement)

Test setup:

  1. Create a ResourceQuota with memory/storage limits in a namespace
  2. Navigate to Administration → ResourceQuotas
  3. View the quota details

Test cases:

  • ✅ Memory quota values display in GiB/MiB format
  • ✅ Storage quota values display in GiB/MiB format
  • ✅ Ephemeral storage values display in GiB/MiB format
  • ✅ CPU and count-based quotas display unchanged
  • ✅ Unit tests pass for humanized values

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Summary by CodeRabbit

  • Enhancements
  • Resource quota values for memory and storage are now displayed in a human-readable GiB format.
  • Used, total used (ACRQ), and maximum capacity fields are formatted consistently across quota rows.
  • If quota values are missing or unavailable, the UI shows a dash instead of blank or raw data.
  • Tests
  • Added coverage to verify memory and storage quota rendering produces the expected GiB outputs.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

…splay

Memory and storage quota values were displayed as raw bytes (e.g., "2147483648")
making them difficult to read. This change applies human-readable formatting
(e.g., "2 GiB") to memory, storage, and ephemeral-storage resource types.

Changes:
- Import humanizeBinaryBytes utility
- Add isBinaryResourceType helper to identify byte-based resources
- Add formatResourceValue helper to conditionally humanize values
- Update ResourceUsageRow to use formatResourceValue for all quota displays
- Add unit tests for memory and storage humanization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ericahinkleRH
ericahinkleRH force-pushed the OCPBUGS-95592-resourcequota-memory-humanize branch from ec68b31 to 2359c76 Compare July 28, 2026 17:44
@ericahinkleRH

Copy link
Copy Markdown
Author

/retest-required

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@ericahinkleRH: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants