Copilot commented on code in PR #12144:
URL: https://github.com/apache/cloudstack/pull/12144#discussion_r3588341071


##########
ui/src/views/compute/DeployVM.vue:
##########
@@ -2333,6 +2336,46 @@ export default {
           console.error('Error fetching guestOsCategories:', e)
         })
     },
+    fetchServiceOfferingCategories () {
+      this.loading.serviceOfferingCategories = true
+      return new Promise((resolve, reject) => {

Review Comment:
   DeployVM passes options.serviceOfferingCategories / 
selectedServiceOfferingCategoryId into ComputeOfferingSelection and updates 
loading.serviceOfferingCategories/options.serviceOfferingCategories, but these 
keys are not initialized in data(). In Vue 2 this can lead to non-reactive 
updates (and in general it introduces undefined state). Initialize the reactive 
keys (or use this.$set when missing) before first assignment so the category 
selector reliably renders and loading state updates.



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -3969,7 +3987,7 @@ public ServiceOffering cloneServiceOffering(final 
CloneServiceOfferingCmd cmd) {
                 diskParams.iopsWriteRate, diskParams.iopsWriteRateMax, 
diskParams.iopsWriteRateMaxLength,
                 diskParams.hypervisorSnapshotReserve, diskParams.cacheMode, 
customParams.storagePolicy, dynamicScalingEnabled,
                 diskOfferingId, diskOfferingStrictness, isCustomized, 
encryptRoot,
-                vgpuProfileId, finalGpuCount, gpuDisplay, purgeResources, 
leaseParams.leaseDuration, leaseParams.leaseExpiryAction);
+                vgpuProfileId, finalGpuCount, gpuDisplay, purgeResources, 
leaseParams.leaseDuration, leaseParams.leaseExpiryAction, 
sourceOffering.getCategoryId());
     }

Review Comment:
   cloneServiceOffering always passes the source offering category 
(sourceOffering.getCategoryId()) into createServiceOffering, so an explicit 
categoryid provided on the clone command (inherited from 
CreateServiceOfferingCmd) is ignored. This makes the clone API/UI unable to 
override the category even though the command advertises that all 
createServiceOffering parameters can be overridden. Compute an effective 
categoryId from cmd.getCategoryId() with fallback to the source offering, 
validate it exists, and pass that value into createServiceOffering.



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -9552,4 +9580,97 @@ public void setScope(String scope) {
             this.scope = scope;
         }
     }
+
+    @Override
+    @ActionEvent(eventType = 
EventTypes.EVENT_SERVICE_OFFERING_CATEGORY_CREATE, eventDescription = "creating 
service offering category")
+    public ServiceOfferingCategory 
createServiceOfferingCategory(CreateServiceOfferingCategoryCmd cmd) {
+        String name = cmd.getName();
+        Integer sortKey = cmd.getSortKey();

Review Comment:
   The new service offering category CRUD paths (create/update/delete) are not 
covered by tests. There are existing 
ConfigurationManager/ConfigurationManagerImpl tests in 
server/src/test/java/com/cloud/configuration/, so adding at least basic unit 
tests for duplicate-name validation, delete-in-use rejection, and update 
validation would help prevent regressions.



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