Damans227 commented on code in PR #14395:
URL: https://github.com/apache/cloudstack/pull/14395#discussion_r4260773892


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3208,8 +3208,11 @@ public UserVm updateVirtualMachine(long id, String 
displayName, String group, Bo
             osTypeId = vm.getGuestOSId();
         }
 
-        if (group != null) {
+        if (StringUtils.isNotBlank(group)) {
             addInstanceToGroup(id, group);
+        } else if (group != null) {
+            // Allow removing an instance from its group when passing an empty 
group on update
+            removeInstanceFromInstanceGroup(vm.getId());

Review Comment:
   should the api doc for group say an empty value takes the instance out of 
its group? cmk and terraform users wont find it otherwise



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3208,8 +3208,11 @@ public UserVm updateVirtualMachine(long id, String 
displayName, String group, Bo
             osTypeId = vm.getGuestOSId();
         }
 
-        if (group != null) {
+        if (StringUtils.isNotBlank(group)) {
             addInstanceToGroup(id, group);
+        } else if (group != null) {
+            // Allow removing an instance from its group when passing an empty 
group on update
+            removeInstanceFromInstanceGroup(vm.getId());

Review Comment:
   can we add a unit test for the empty group case? this new path isnt covered



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