-
Notifications
You must be signed in to change notification settings - Fork 736
OCPBUGS-95592: Humanize memory and storage values in ResourceQuota display #16874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ import { SectionHeading } from './utils/headings'; | |
| import { navFactory } from './utils/horizontal-nav'; | ||
| import { ResourceLink } from './utils/resource-link'; | ||
| import { ResourceSummary } from './utils/details-page'; | ||
| import { convertToBaseValue } from './utils/units'; | ||
| import { convertToBaseValue, humanizeBinaryBytes } from './utils/units'; | ||
| import { FieldLevelHelp } from './utils/field-level-help'; | ||
| import { useAccessReview } from './utils/rbac'; | ||
| import { LabelList } from './utils/label-list'; | ||
|
|
@@ -82,6 +82,22 @@ const getQuotaResourceTypes = (quota) => { | |
| return _.keys(specHard).sort(); | ||
| }; | ||
|
|
||
| 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') | ||
| ); | ||
| }; | ||
|
|
||
| const formatResourceValue = (value, resourceType) => { | ||
| if (value === null || value === undefined) { | ||
| return DASH; | ||
| } | ||
| return isBinaryResourceType(resourceType) ? humanizeBinaryBytes(value).string : value; | ||
| }; | ||
|
Comment on lines
+94
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Preserve numeric zero values.
🤖 Prompt for AI Agents |
||
|
|
||
| export const getACRQResourceUsage = (quota, resourceType, namespace) => { | ||
| let used; | ||
| if (namespace) { | ||
|
|
@@ -190,9 +206,9 @@ export const ResourceUsageRow = ({ quota, resourceType, namespace = undefined }) | |
| <Td visibility={['hidden', 'visibleOnMd']} className="co-resource-quota-icon"> | ||
| <UsageIcon percent={percent.namespace} /> | ||
| </Td> | ||
| <Td>{used.namespace}</Td> | ||
| <Td>{totalUsed}</Td> | ||
| <Td>{max}</Td> | ||
| <Td>{formatResourceValue(used.namespace, resourceType)}</Td> | ||
| <Td>{formatResourceValue(totalUsed, resourceType)}</Td> | ||
| <Td>{formatResourceValue(max, resourceType)}</Td> | ||
| </Tr> | ||
| ); | ||
| } | ||
|
|
@@ -204,8 +220,8 @@ export const ResourceUsageRow = ({ quota, resourceType, namespace = undefined }) | |
| <Td visibility={['hidden', 'visibleOnMd']} className="co-resource-quota-icon"> | ||
| <UsageIcon percent={percent} /> | ||
| </Td> | ||
| <Td>{used}</Td> | ||
| <Td>{max}</Td> | ||
| <Td>{formatResourceValue(used, resourceType)}</Td> | ||
| <Td>{formatResourceValue(max, resourceType)}</Td> | ||
| </Tr> | ||
| ); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
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:
Repository: openshift/console
Length of output: 50374
🏁 Script executed:
Repository: openshift/console
Length of output: 17646
🏁 Script executed:
Repository: openshift/console
Length of output: 5826
🏁 Script executed:
Repository: openshift/console
Length of output: 29271
Match only explicit binary quota keys.
includes('storage')also matches count-based keys likestorageclass.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
Source: MCP tools