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-like resource types) are now rendered in human-readable GiB format.
    • Used, total used (ACRQ), and maximum capacity fields are formatted consistently within each quota row.
    • If quota values are missing (null/undefined), the UI displays a dash instead of leaving cells blank or showing raw data.
  • Tests
    • Added coverage to verify ResourceUsageRow displays the expected GiB outputs for memory and storage quotas.

@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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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 covers root cause, solution, test setup, test cases, and required sections, with only minor placeholders left.
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 All changed test titles are static strings; none include dynamic IDs, timestamps, namespaces, or generated values.
Test Structure And Quality ✅ Passed PR adds React unit tests, not Ginkgo cluster tests; the new it blocks are single-purpose and have no resource lifecycle or timeout concerns.
Microshift Test Compatibility ✅ Passed Only frontend unit tests and a UI formatting helper changed; no new Ginkgo e2e tests, MicroShift-sensitive APIs, or unsupported OpenShift resources were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only frontend unit tests were added; no Ginkgo/e2e tests or SNO-sensitive multi-node assumptions are present.
Topology-Aware Scheduling Compatibility ✅ Passed PR only changes frontend quota rendering/tests; diff contains no manifests, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed Changed files add pure formatting helpers/tests only; no main/init/TestMain/BeforeSuite/RunSpecs or stdout writes were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Changed files are frontend unit tests/component code; no Ginkgo e2e tests, IPv4 literals, or external connectivity were found.
No-Weak-Crypto ✅ Passed No weak-crypto algorithms, custom crypto, or secret/token comparisons appear in the changed files; only quota UI formatting changed.
Container-Privileges ✅ Passed PR only changes frontend quota formatting/tests; no container/K8s manifests or privilege settings are introduced.
No-Sensitive-Data-In-Logs ✅ Passed No new logging calls or sensitive literals appear in the touched files; the patch only formats quota values.
✨ 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-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.

@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

@Leo6Leo

Leo6Leo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci openshift-ci Bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jul 29, 2026
@ericahinkleRH

Copy link
Copy Markdown
Author

/test backend

@Leo6Leo

Leo6Leo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@nader-ziada

Copy link
Copy Markdown

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ericahinkleRH, nader-ziada
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

@ericahinkleRH
ericahinkleRH force-pushed the OCPBUGS-95592-resourcequota-memory-humanize branch from 2359c76 to 1352ece Compare July 30, 2026 17:44
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

…splay

This change improves the readability of ResourceQuota displays by
formatting memory and storage-related values as human-readable binary
units (e.g., GiB, MiB) instead of raw byte values.

Key changes:
- Add humanizeBinaryBytes import from utils/units
- Add isBinaryResourceType() helper to identify memory/storage resources
- Add formatResourceValue() to conditionally format values
- Update ResourceUsageRow to use formatResourceValue for all displayed values

Resources affected:
- memory (e.g., limits.memory, requests.memory)
- storage (e.g., persistentvolumeclaims, requests.storage)
- ephemeral-storage

Jira: https://issues.redhat.com/browse/OCPBUGS-95592
@ericahinkleRH
ericahinkleRH force-pushed the OCPBUGS-95592-resourcequota-memory-humanize branch from 1352ece to f8d1b56 Compare July 30, 2026 19:18
@Leo6Leo

Leo6Leo commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-gcp-console

1 similar comment
@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-gcp-console

@openshift-ci

openshift-ci Bot commented Jul 31, 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants