Skip to content

UI: allow memory setting in flex compute offering in GiB with unit selector (#14082) - #14413

Open
saurabhkushwaha438 wants to merge 1 commit into
apache:mainfrom
saurabhkushwaha438:issue-14082-flex-memory-gib
Open

saurabhkushwaha438 wants to merge 1 commit into
apache:mainfrom
saurabhkushwaha438:issue-14082-flex-memory-gib

Conversation

@saurabhkushwaha438

Copy link
Copy Markdown
Contributor

Description

Fixes #14082

1. Conversion from MiB to GiB (Display & Rounding)

  • Binary conversion is used (1 GiB = 1024 MiB).
  • When offerings with predefined constraints or initial values are loaded in MiB, or when switching from MiB to GiB:
    $$\text{displayValue} = \text{parseFloat}\left(\left(\frac{\text{rawMemory}}{1024}\right)\text{.toFixed(2)}\right)$$
  • The display value is rounded to 2 decimal places to keep the UI clean, readable, and intuitive for users.
  • Slider step dynamically adjusts:
    • In GiB mode: step is set to 0.01 (or smaller for sub-GiB offerings) with precision 2.
    • In MiB mode: step is set to 1 with integer precision 0.

2. Conversion from GiB to MiB (Backend Value Emission)

  • CloudStack APIs and backend services expect memory allocations in integer MiB.
  • When the user selects or inputs memory in GiB:
    $$\text{memoryInMiB} = \text{Math.round}(\text{displayValue} \times 1024)$$
  • Exact Boundary Protection: If a compute offering has minimum/maximum memory constraints (minMemory / maxMemory), selecting the exact minimum or maximum bound in GiB directly maps to the exact integer minMemory or maxMemory in MiB to eliminate any potential off-by-one rounding discrepancies.

💬 Feedback Needed: Fractional GiB to Integer MiB Rounding

  • Observation: Converting decimal GiB values to MiB often produces fractional values (e.g., 1.51 GiB × 1024 = 1546.24 MiB).
  • Current Behavior: The UI rounds this to the nearest integer (1546 MiB), which is then emitted in the API payload and consumed by backend hypervisor managers.
  • Reviewer Input: Looking for maintainer feedback on whether standard nearest-integer rounding (Math.round) is acceptable, or if we should apply ceiling (Math.ceil) to guarantee the VM always receives at least the requested GiB amount.
bandicam.2026-10-16.10-21-12-210.mp4

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI: Please change memory setting in flex compute offering from MiB to GiB

1 participant