suryag1201 commented on code in PR #14413:
URL: https://github.com/apache/cloudstack/pull/14413#discussion_r4443405382


##########
ui/src/views/compute/wizard/ComputeSelection.vue:
##########
@@ -241,18 +315,37 @@ export default {
     updateComputeCpuSpeed (value) {
       this.$emit('update-compute-cpuspeed', this.cpuSpeedInputDecorator, value)
     },
-    updateComputeMemory (value) {
-      if (!value) this.memoryInputValue = 0
-      if (!this.validateInput('memory', value)) {
+    updateComputeMemory (displayValue) {
+      if (displayValue === null || displayValue === undefined || displayValue 
=== '') {
+        this.memoryDisplayValue = 0
+        this.memoryInputValue = 0
+      } else {
+        this.memoryDisplayValue = displayValue
+      }
+      if (!this.validateInput('memory', displayValue)) {
         return
       }
-      this.$emit('update-compute-memory', this.memoryInputDecorator, value)
+      let memoryInMiB
+      if (this.memoryUnit === 'GiB') {

Review Comment:
   @saurabhkushwaha438 The memory field and its hover text show different 
amounts of memory value at the minimum and maximum of a constrained offering.
   With min memory 100 MiB, the GiB control shows 0.25 GiB. Hovering it shows 
"Exact: 0.09765625 GiB (100 MiB)", and deploy sends 100 MiB. 0.25 GiB is 256 
MiB, so the VM is created with a smaller size than the field shows. The same 
happens at the maximum.
   
   <img width="985" height="281" alt="Image" 
src="https://github.com/user-attachments/assets/90fe6f30-813b-48c0-a502-35978329840d";
 />
   
   <img width="985" height="329" alt="Image" 
src="https://github.com/user-attachments/assets/564ab9d4-1bd0-4712-9959-874efc60646c";
 />



##########
ui/src/views/compute/wizard/ComputeSelection.vue:
##########
@@ -57,23 +57,40 @@
         </a-col>
         <a-col :md="colContraned" :lg="colContraned" v-if="isCustomized">
           <a-form-item
-            :label="$t('label.memory.mb')"
+            :label="$t('label.memory')"

Review Comment:
   @saurabhkushwaha438 An out-of-range GiB value is rejected with "Invalid 
memory value, specify a value between 32 and 2147483647" and the message does 
not say the unit (MiB or GiB).
   For example:  0.01 GiB is sent as 10 MiB and hits this error.
   
   <img width="1385" height="261" alt="Image" 
src="https://github.com/user-attachments/assets/da02931f-312a-4d7b-8ed1-6e3d98736850";
 />



##########
ui/src/views/compute/wizard/ComputeSelection.vue:
##########
@@ -241,18 +315,37 @@ export default {
     updateComputeCpuSpeed (value) {
       this.$emit('update-compute-cpuspeed', this.cpuSpeedInputDecorator, value)
     },
-    updateComputeMemory (value) {
-      if (!value) this.memoryInputValue = 0
-      if (!this.validateInput('memory', value)) {
+    updateComputeMemory (displayValue) {
+      if (displayValue === null || displayValue === undefined || displayValue 
=== '') {
+        this.memoryDisplayValue = 0
+        this.memoryInputValue = 0
+      } else {
+        this.memoryDisplayValue = displayValue
+      }
+      if (!this.validateInput('memory', displayValue)) {
         return
       }
-      this.$emit('update-compute-memory', this.memoryInputDecorator, value)
+      let memoryInMiB
+      if (this.memoryUnit === 'GiB') {
+        if (this.isConstrained && displayValue === this.minMemoryInUnit) {
+          memoryInMiB = this.minMemory
+        } else if (this.isConstrained && displayValue === 
this.maxMemoryInUnit) {
+          memoryInMiB = this.maxMemory
+        } else {
+          memoryInMiB = Math.round(displayValue * 1024)
+        }
+      } else {
+        memoryInMiB = Math.round(displayValue)
+      }
+
+      this.memoryInputValue = memoryInMiB
+      this.$emit('update-compute-memory', this.memoryInputDecorator, 
memoryInMiB)
     },
     validateInput (input, value) {
       this.errors[input].status = ''
       this.errors[input].message = ''
 
-      if (value === null || value === undefined || value.length === 0) {
+      if (value === null || value === undefined || value.length === 0 || value 
=== '' || value === 0) {

Review Comment:
   @saurabhkushwaha438 Setting the CPU value to 0 does not clear the previously 
stored CPU count in the form. For example, after selecting a constrained 
offering, the form stores CPU = 2. When switching to an unconstrained custom 
offering, the CPU field displays 0 with the validation message "Please enter 
input". However, instance creation still proceeds successfully, and the VM is 
created with 2 CPUs, as the previously stored value is retained.



##########
ui/src/views/compute/wizard/ComputeSelection.vue:
##########
@@ -241,18 +315,37 @@ export default {
     updateComputeCpuSpeed (value) {
       this.$emit('update-compute-cpuspeed', this.cpuSpeedInputDecorator, value)
     },
-    updateComputeMemory (value) {
-      if (!value) this.memoryInputValue = 0
-      if (!this.validateInput('memory', value)) {
+    updateComputeMemory (displayValue) {
+      if (displayValue === null || displayValue === undefined || displayValue 
=== '') {
+        this.memoryDisplayValue = 0
+        this.memoryInputValue = 0
+      } else {
+        this.memoryDisplayValue = displayValue
+      }
+      if (!this.validateInput('memory', displayValue)) {
         return
       }
-      this.$emit('update-compute-memory', this.memoryInputDecorator, value)
+      let memoryInMiB
+      if (this.memoryUnit === 'GiB') {
+        if (this.isConstrained && displayValue === this.minMemoryInUnit) {
+          memoryInMiB = this.minMemory
+        } else if (this.isConstrained && displayValue === 
this.maxMemoryInUnit) {
+          memoryInMiB = this.maxMemory
+        } else {
+          memoryInMiB = Math.round(displayValue * 1024)
+        }
+      } else {
+        memoryInMiB = Math.round(displayValue)

Review Comment:
   @saurabhkushwaha438 Switching between MiB and GiB updates only the displayed 
memory value, while the deploy form continues to retain the previously entered 
MiB value.
   
   On an unconstrained custom offering:
   - Enter 1100 MiB and then switch to GiB. The field displays 1.00 GiB, but 
when the instance is created, the deploy request still sends 1100 MiB (where 
1.00 GiB = 1024 MiB).
   - Enter 100 MiB and then switch to GiB. The field displays 0 GiB, but 
instance creation still succeeds, and the deploy request sends 100 MiB, 
resulting in a VM being created with 100 MiB of memory.



##########
ui/src/views/compute/wizard/ComputeSelection.vue:
##########
@@ -192,6 +211,37 @@ export default {
       }
 
       return 8
+    },
+    minMemoryInUnit () {
+      if (!this.minMemory) return 0
+      if (this.memoryUnit === 'GiB') {
+        return Math.ceil(this.minMemory / 256) * 0.25
+      }
+      return this.minMemory
+    },
+    maxMemoryInUnit () {
+      if (!this.maxMemory) return 0
+      if (this.memoryUnit === 'GiB') {
+        return Math.max(this.minMemoryInUnit, Math.floor(this.maxMemory / 256) 
* 0.25)

Review Comment:
   @saurabhkushwaha438 For custom offerings with a memory range like 2000-2300 
MiB, the field is effectively restricted to 2.00 GiB when the unit is switched 
to GiB. The slider cannot be moved to any other value within the allowed range, 
preventing selection of valid memory sizes between 2000 MiB and 2300 MiB.



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