saurabhkushwaha438 commented on PR #14413: URL: https://github.com/apache/cloudstack/pull/14413#issuecomment-6581715027
> ### 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: > > displayValue > = > parseFloat > > ( > > ( > > rawMemory > 1024 > > ) > > .toFixed(2) > ) > * 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**: > > memoryInMiB > = > Math.round > ( > displayValue > × > 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 @suryag1201 please go through this and then later i also make other changes according to feedback i was getting and here is other Commits Description ui: allow memory setting in flex compute offering in GiB with 0.25 GiB step (https://github.com/apache/cloudstack/issues/14082) - Add compact unit selector dropdown (GiB/MiB) for flex compute offerings - Use fixed 0.25 GiB steps in GiB mode (binary-exact to 256 MiB intervals, zero rounding errors) - Maintain integer MiB as authoritative internal state to prevent lossy conversion on load - Default to GiB for 256 MiB multiples and MiB for arbitrary sizes (e.g. 1500 MiB) - Add hover tooltip to display exact converted values -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
