saurabhkushwaha438 opened a new pull request, #14413:
URL: https://github.com/apache/cloudstack/pull/14413

   ### 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.
   
   
https://github.com/user-attachments/assets/74c9276d-83be-4389-b676-950bfbb9cf1f
   
   
   
   


-- 
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]

Reply via email to