You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/04/07 13:46:47 UTC

[GitHub] [cloudstack] GutoVeronezi opened a new pull request #4878: Support vm dynamic scaling with kvm

GutoVeronezi opened a new pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878


   ### Description
   ACS has an API to scale VMs `scaleVirtualMachine`, however dynamic scale of VMs is limited to `XenServer` and `VMWare`.
   
   This PR intends suport live scale for VMs on `KVM`.
   
   When we are using a custom service offerings, KVM's XML only receives the boot memory, but with this changes it will receive the max values defined in the service offerings. If it is a unconstrainced service offering, max values will be the `vm.serviceoffering.cpu.cores.max` and `vm.serviceoffering.ram.size.max` values . If they are `0`, max values will be host or last host capacities.
   
   ### Types of changes
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   - [ ] Major
   - [x] Minor
   
   ### How Has This Been Tested?
   I created unit tests for the code that is being introduced here. Moreover, it has been tested locally in a test lab. I created multiples VMs with multiples definitions and tested API with they:
   
   | VM STATE | INIT CPU CORES | UP TO | INIT RAM SIZE | UP TO | SERVICE OFFERING | RAM SERVICE OFFERING | CPU SERVICE OFFERING | MAX RAM CONFIG | MAX CPU CONFIG | EXPECTED RESULT |
   | -------- | --------- | ----- | -------- | ----- | ---------------- | -------------------- | -------------------- | -------------- | -------------- | --------------- |
   | RUNNING | 1 | 3 | 64 | 128 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | RUNNING | 1 | 2 | 64 | 257 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | RUNNING | 1 | 2 | 128 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | RUNNING | 2 | 1 | 64 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | STOPPED | 1 | 3 | 64 | 128 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | STOPPED | 1 | 2 | 64 | 257 | CONSTRAINED | 256 | 2 | 512 | 4 | FAIL |
   | RUNNING | 1 | 2 | 64 | 128 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 1 | 64 | 128 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 2 | 64 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 2 | 128 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | STOPPED | 2 | 1 | 64 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 1 | 64 | 128 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 1 | 128 | 64 | CONSTRAINED | 256 | 2 | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 2 | 128 | 64 | UNCONSTRAINED |  |  | 512 | 4 | FAIL |
   | RUNNING | 2 | 1 | 64 | 64 | UNCONSTRAINED |  |  | 512 | 4 | FAIL |
   | STOPPED | 1 | 2 | 128 | 64 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | STOPPED | 2 | 1 | 64 | 64 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 3 | 64 | 128 | UNCONSTRAINED |  |  | 512 | 4 | FAIL |
   | STOPPED | 1 | 1 | 64 | 4000 | UNCONSTRAINED |  |  | 512 | 4 | FAIL |
   | RUNNING | 1 | 2 | 64 | 128 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 1 | 64 | 128 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 2 | 64 | 64 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 2 | 64 | 257 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | RUNNING | 1 | 1 | 64 | 700 | UNCONSTRAINED |  |  | 0 | 0 | SUCCESS |
   | STOPPED | 1 | 2 | 64 | 128 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 1 | 64 | 128 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 2 | 64 | 64 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 2 | 64 | 257 | UNCONSTRAINED |  |  | 512 | 4 | SUCCESS |
   | STOPPED | 1 | 1 | 64 | 700 | UNCONSTRAINED |  |  | 512 | 4 | FAIL |
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scalling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-809198936


   ¿@wido @weizhouapache @ravening @GabrielBrascher , can you guys look at this please?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-888970859


   @DaanHoogland, I didn't check the latest changes. I will do it later today and let you know


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GabrielBrascher commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GabrielBrascher commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902160435


   Manual tests LGTM.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-888968222


   @slavkap does this LGTY? cc @nvazquez .


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-888650372


   <b>Trillian test result (tid-1393)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 34439 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1393-kvm-centos7.zip
   Smoke tests completed. 89 look OK, 0 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r654481594



##########
File path: engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4684,11 +4683,15 @@ private VMInstanceVO orchestrateReConfigureVm(String vmUuid, ServiceOffering old
                 new ScaleVmCommand(vm.getInstanceName(), newServiceOffering.getCpu(), minSpeed,
                         newServiceOffering.getSpeed(), minMemory * 1024L * 1024L, newServiceOffering.getRamSize() * 1024L * 1024L, newServiceOffering.getLimitCpuUse());
 
-        Long dstHostId = vm.getHostId();
+        scaleVmCommand.getVirtualMachine().setId(vm.getId());
+        scaleVmCommand.getVirtualMachine().setUuid(vm.getUuid());
+        scaleVmCommand.getVirtualMachine().setType(vm.getType());
 
-        if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
-            HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
-            Map<String, String> details = hvGuru.getClusterSettings(vm.getId());
+        final Long dstHostId = vm.getHostId();
+        if(vm.getHypervisorType().equals(HypervisorType.VMware)) {
+            final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
+            Map<String, String> details = null;
+            details = hvGuru.getClusterSettings(vm.getId());

Review comment:
       @DaanHoogland this was a lack of attention. Unnecessary changes undone, thanks.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902556566


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] wido commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
wido commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-815532753


   > @wido We already have the API `resizeVolume`, which is designed to scale the root disk as well as data disks, and it works with VMs in `stopped` or `running` states.
   > 
   > This API `scaleVirtualMachine` was first designed to scale computing resources (`memory`, `cpuNumber` and `cpuSpeed`). I think we should not mix these two concepts here.
   
   After reading the code and comments from @GabrielBrascher I understand this code only works with custom service offerings, correct?
   
   If so, please disregard my comments.
   
   Otherwise, with PR #4341 merged we now have the option to make the root disk size a condition of the service offering. Thus when changing the offering one needs to make sure that the root disk is also resized according to the new offering.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-887552585


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian. SL-JID 661


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865555942


   @GutoVeronezi, I've tested this with few use cases, and it works as expected. However, I've hit one problem, but not sure if it has to be fixed in this PR:
   - Create unconstrained service offering
   - disable `enable.dynamic.scale.vm`
   - Deploy VM with the new offering
   - enable `enable.dynamic.scale.vm`
   - update VM with `isdynamicallyscalable=true`
   - try to scale the VM 
   
   This error occurs 
   
   > 2021-06-22 07:46:02,730 WARN  [resource.wrapper.LibvirtScaleVmCommandWrapper] (agentRequest-Handler-5:null) (logid:8f9fc53e) Unable to scale com.cloud.agent.api.to.VirtualMachineTO@495dee84 memory to [2097152 KiB] and cpu cores to [4] due to [unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined].
   > org.libvirt.LibvirtException: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-896575185


   @DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866886931


   @slavkap I added a validation when dynamic scaling the VM and returned a proper message to the user, in case it is not prepared, that I think may direct they.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902188825


   @GabrielBrascher done, thanks.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865058066


   @GabrielBrascher could you review this?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865990220


   @slavkap thanks for testing this feature.
   
   QEMU demands the DOM to be prepared to support CPU scaling and hotplug memory. This preparing is made on VM deploy. ACS verifies if the service offering is dynamic, VM has dynamic scale enabled and global setting `enable.dynamic.scale.vm` as `true`:
   
   https://github.com/apache/cloudstack/blob/607dc234adb16043bd8a2851b56da3e129e90139/server/src/main/java/com/cloud/hypervisor/KVMGuru.java#L180-L186
   
   If they all are enabled and there is a difference between current and max (memory/CPU), the DOM is prepared with the following code:
   https://github.com/apache/cloudstack/blob/607dc234adb16043bd8a2851b56da3e129e90139/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java#L268-L281
   
   Therefore, if you deploy the VM with the global setting as `false`, it will not prepare the DOM and will result in an error, as `org.libvirt.LibvirtException: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined`, when trying to scale it.
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-890070534


   Thanks, @GutoVeronezi :)


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] fdalsotto commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
fdalsotto commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r611491473



##########
File path: utils/src/main/java/org/apache/cloudstack/utils/bytescale/ByteScaleUtils.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cloudstack.utils.bytescale;
+
+/**
+ * This class provides a facility to convert bytes through his scales (b, Kib, Kb, Mib, Mb...).
+ *
+ */
+public class ByteScaleUtils {
+
+    public static final int KiB = 1024;

Review comment:
       getting myself more familiar with this code base so apologies if the comment isn't good:
   could we use org.apache.commons.io.FileUtils instead of hardcoding 1024 in multiple places in the class?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866379553


   > @GutoVeronezi, I understand your point, but I think this is kind of a problem for the users. I mean that the update of the virtual machine to support dynamic scaling has to be disabled in this case, or when scaling such a VM, the `maxMemory` tag has to be set to the Domain (I don't know if this option is possible)
   
   As we are changing the settings between deploy and scaling, it creates an inconsistency in the validations.    
   About manually adding the `maxMemory` tag at runtime, we would need to change/add some others definitions too, like numa cells in cpu; Also Libvirt do not allow to resize maximum memory on active domains.
   
   Do you have any suggestion about how we can solve this?
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-884717161


   tests successfull but conflict with new merges. @GutoVeronezi can you have a look?


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902949145


   <b>Trillian test result (tid-1736)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 33654 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1736-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_snapshots.py
   Smoke tests completed. 89 look OK, 0 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866890130


   Thanks, @GutoVeronezi! :) 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GabrielBrascher commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r609057901



##########
File path: server/src/main/java/com/cloud/hypervisor/KVMGuru.java
##########
@@ -112,32 +121,147 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
         VirtualMachineTO to = toVirtualMachineTO(vm);
         setVmQuotaPercentage(to, vm);
 
-        if (dpdkHelper.isDpdkvHostUserModeSettingOnServiceOffering(vm)) {
-            dpdkHelper.setDpdkVhostUserMode(to, vm);
+        enableDpdkIfNeeded(vm, to);
+
+        VirtualMachine virtualMachine = vm.getVirtualMachine();
+        Long hostId = virtualMachine.getHostId();
+        HostVO host = hostId == null ? null : _hostDao.findById(hostId);
+
+        // Determine the VM's OS description
+        configureVmOsDescription(virtualMachine, to, host);
+
+        configureVmMemoryAndCpuCores(to, host, virtualMachine, vm);
+        return to;
+    }
+
+    protected void configureVmOsDescription(VirtualMachine virtualMachine, VirtualMachineTO virtualMachineTo, HostVO hostVo) {
+        GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(virtualMachine.getGuestOSId());
+        String guestOsDisplayName = guestOS.getDisplayName();
+        virtualMachineTo.setOs(guestOsDisplayName);
+        GuestOSHypervisorVO guestOsMapping = null;
+
+        if (hostVo != null) {
+            guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), hostVo.getHypervisorVersion());
         }
 
-        if (to.getType() == VirtualMachine.Type.User && MapUtils.isNotEmpty(to.getExtraConfig()) &&
-                to.getExtraConfig().containsKey(DpdkHelper.DPDK_NUMA) && to.getExtraConfig().containsKey(DpdkHelper.DPDK_HUGE_PAGES)) {
-            for (final NicTO nic : to.getNics()) {
+        if (guestOsMapping == null || hostVo == null) {
+            virtualMachineTo.setPlatformEmulator(guestOsDisplayName == null ? "Other" : guestOsDisplayName);
+        } else {
+            virtualMachineTo.setPlatformEmulator(guestOsMapping.getGuestOsName());
+        }
+    }
+
+    protected void enableDpdkIfNeeded(VirtualMachineProfile virtualMachineProfile, VirtualMachineTO virtualMachineTo) {
+        if (dpdkHelper.isDpdkvHostUserModeSettingOnServiceOffering(virtualMachineProfile)) {
+            dpdkHelper.setDpdkVhostUserMode(virtualMachineTo, virtualMachineProfile);
+        }
+
+        if (virtualMachineTo.getType() == VirtualMachine.Type.User && MapUtils.isNotEmpty(virtualMachineTo.getExtraConfig()) &&
+          virtualMachineTo.getExtraConfig().containsKey(DpdkHelper.DPDK_NUMA) && virtualMachineTo.getExtraConfig().containsKey(DpdkHelper.DPDK_HUGE_PAGES)) {
+            for (final NicTO nic : virtualMachineTo.getNics()) {
                 nic.setDpdkEnabled(true);
             }
         }
+    }
+
+    protected void configureVmMemoryAndCpuCores(VirtualMachineTO virtualMachineTo, HostVO hostVo, VirtualMachine virtualMachine, VirtualMachineProfile virtualMachineProfile) {
+        String vmDescription = virtualMachineTo.toString();
+
+        Pair<Long, Integer> max = getHostMaxMemoryAndCpuCores(hostVo, virtualMachine, vmDescription);
+
+        Long maxHostMemory = max.first();
+        Integer maxHostCpuCore = max.second();
+
+        Long minMemory = virtualMachineTo.getMinRam();
+        Long maxMemory = minMemory;
+        Integer minCpuCores = virtualMachineTo.getCpus();
+        Integer maxCpuCores = minCpuCores;
+
+        ServiceOfferingVO serviceOfferingVO = serviceOfferingDao.findById(virtualMachineProfile.getId(), virtualMachineProfile.getServiceOfferingId());
+        if (serviceOfferingVO.isDynamic() && virtualMachineTo.isEnableDynamicallyScaleVm()) {
+            serviceOfferingDao.loadDetails(serviceOfferingVO);
+
+            maxMemory = getVmMaxMemory(serviceOfferingVO, vmDescription, maxHostMemory);
+            maxCpuCores = getVmMaxCpuCores(serviceOfferingVO, vmDescription, maxHostCpuCore);
+        }
+
+        virtualMachineTo.setRam(minMemory, maxMemory);
+        virtualMachineTo.setCpus(minCpuCores);
+        virtualMachineTo.setVcpuMaxLimit(maxCpuCores);
+    }
+
+    protected Pair<Long, Integer> getHostMaxMemoryAndCpuCores(HostVO host, VirtualMachine virtualMachine, String vmDescription){
+        Long maxHostMemory = Long.MAX_VALUE;
+        Integer maxHostCpuCore = Integer.MAX_VALUE;
 
-        // Determine the VM's OS description
-        GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId());
-        to.setOs(guestOS.getDisplayName());
-        HostVO host = _hostDao.findById(vm.getVirtualMachine().getHostId());
-        GuestOSHypervisorVO guestOsMapping = null;
         if (host != null) {
-            guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());
+            return new Pair<>(host.getTotalMemory(), host.getCpus());
         }
-        if (guestOsMapping == null || host == null) {
-            to.setPlatformEmulator(guestOS.getDisplayName() == null ? "Other" : guestOS.getDisplayName());
+
+        Long lastHostId = virtualMachine.getLastHostId();
+        s_logger.info(String.format("%s is not running; therefore, we use the last host [%s] that the VM was running on to derive the unconstrained service offering max CPU and memory.", vmDescription, lastHostId));
+
+        HostVO lastHost = lastHostId == null ? null : _hostDao.findById(lastHostId);
+        if (lastHost != null) {
+            maxHostMemory = lastHost.getTotalMemory();
+            maxHostCpuCore = lastHost.getCpus();
+            s_logger.debug(String.format("Retrieved memory and cpu max values {\"memory\": %s, \"cpu\": %s} from %s last %s.", maxHostMemory, maxHostCpuCore, vmDescription, lastHost.toString()));
         } else {
-            to.setPlatformEmulator(guestOsMapping.getGuestOsName());
+            s_logger.warn(String.format("%s host [%s] and last host [%s] are null. Using 'Long.MAX_VALUE' [%s] and 'Integer.MAX_VALUE' [%s] as max memory and cpu cores.", vmDescription, virtualMachine.getHostId(), lastHostId, maxHostMemory, maxHostCpuCore));
         }
 
-        return to;
+        return new Pair<>(maxHostMemory, maxHostCpuCore);
+    }
+
+    protected Long getVmMaxMemory(ServiceOfferingVO serviceOfferingVO, String vmDescription, Long maxHostMemory) {
+        String serviceOfferingDescription = serviceOfferingVO.toString();
+
+        Long maxMemory;
+        Integer customOfferingMaxMemory = NumberUtils.createInteger(serviceOfferingVO.getDetail(ApiConstants.MAX_MEMORY));
+        Integer maxMemoryConfig = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.value();
+        if (customOfferingMaxMemory != null) {
+            s_logger.debug(String.format("Using 'Custom unconstrained' %s max memory value [%sMb] as %s memory.", serviceOfferingDescription, customOfferingMaxMemory, vmDescription));

Review comment:
       Shouldn't it be _Custom constrained_?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-860750098


   Can anyone review this?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865331519


   <b>Trillian test result (tid-1024)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 45222 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1024-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
   Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
   Intermittent failure detected: /marvin/tests/smoke/test_outofbandmanagement.py
   Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
   Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
   Smoke tests completed. 85 look OK, 3 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 | `Failure` | 546.86 | test_internal_lb.py
   test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | `Failure` | 336.76 | test_routers_network_ops.py
   test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | `Failure` | 339.90 | test_routers_network_ops.py
   test_02_redundant_VPC_default_routes | `Failure` | 1177.75 | test_vpc_redundant.py
   test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | `Failure` | 499.68 | test_vpc_redundant.py
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r616227163



##########
File path: server/src/main/java/com/cloud/hypervisor/KVMGuru.java
##########
@@ -112,32 +121,147 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
         VirtualMachineTO to = toVirtualMachineTO(vm);
         setVmQuotaPercentage(to, vm);
 
-        if (dpdkHelper.isDpdkvHostUserModeSettingOnServiceOffering(vm)) {
-            dpdkHelper.setDpdkVhostUserMode(to, vm);
+        enableDpdkIfNeeded(vm, to);
+
+        VirtualMachine virtualMachine = vm.getVirtualMachine();
+        Long hostId = virtualMachine.getHostId();
+        HostVO host = hostId == null ? null : _hostDao.findById(hostId);
+
+        // Determine the VM's OS description
+        configureVmOsDescription(virtualMachine, to, host);
+
+        configureVmMemoryAndCpuCores(to, host, virtualMachine, vm);
+        return to;
+    }
+
+    protected void configureVmOsDescription(VirtualMachine virtualMachine, VirtualMachineTO virtualMachineTo, HostVO hostVo) {
+        GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(virtualMachine.getGuestOSId());
+        String guestOsDisplayName = guestOS.getDisplayName();
+        virtualMachineTo.setOs(guestOsDisplayName);
+        GuestOSHypervisorVO guestOsMapping = null;
+
+        if (hostVo != null) {
+            guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), hostVo.getHypervisorVersion());
         }
 
-        if (to.getType() == VirtualMachine.Type.User && MapUtils.isNotEmpty(to.getExtraConfig()) &&
-                to.getExtraConfig().containsKey(DpdkHelper.DPDK_NUMA) && to.getExtraConfig().containsKey(DpdkHelper.DPDK_HUGE_PAGES)) {
-            for (final NicTO nic : to.getNics()) {
+        if (guestOsMapping == null || hostVo == null) {
+            virtualMachineTo.setPlatformEmulator(guestOsDisplayName == null ? "Other" : guestOsDisplayName);
+        } else {
+            virtualMachineTo.setPlatformEmulator(guestOsMapping.getGuestOsName());
+        }
+    }
+
+    protected void enableDpdkIfNeeded(VirtualMachineProfile virtualMachineProfile, VirtualMachineTO virtualMachineTo) {
+        if (dpdkHelper.isDpdkvHostUserModeSettingOnServiceOffering(virtualMachineProfile)) {
+            dpdkHelper.setDpdkVhostUserMode(virtualMachineTo, virtualMachineProfile);
+        }
+
+        if (virtualMachineTo.getType() == VirtualMachine.Type.User && MapUtils.isNotEmpty(virtualMachineTo.getExtraConfig()) &&
+          virtualMachineTo.getExtraConfig().containsKey(DpdkHelper.DPDK_NUMA) && virtualMachineTo.getExtraConfig().containsKey(DpdkHelper.DPDK_HUGE_PAGES)) {
+            for (final NicTO nic : virtualMachineTo.getNics()) {
                 nic.setDpdkEnabled(true);
             }
         }
+    }
+
+    protected void configureVmMemoryAndCpuCores(VirtualMachineTO virtualMachineTo, HostVO hostVo, VirtualMachine virtualMachine, VirtualMachineProfile virtualMachineProfile) {
+        String vmDescription = virtualMachineTo.toString();
+
+        Pair<Long, Integer> max = getHostMaxMemoryAndCpuCores(hostVo, virtualMachine, vmDescription);
+
+        Long maxHostMemory = max.first();
+        Integer maxHostCpuCore = max.second();
+
+        Long minMemory = virtualMachineTo.getMinRam();
+        Long maxMemory = minMemory;
+        Integer minCpuCores = virtualMachineTo.getCpus();
+        Integer maxCpuCores = minCpuCores;
+
+        ServiceOfferingVO serviceOfferingVO = serviceOfferingDao.findById(virtualMachineProfile.getId(), virtualMachineProfile.getServiceOfferingId());
+        if (serviceOfferingVO.isDynamic() && virtualMachineTo.isEnableDynamicallyScaleVm()) {
+            serviceOfferingDao.loadDetails(serviceOfferingVO);
+
+            maxMemory = getVmMaxMemory(serviceOfferingVO, vmDescription, maxHostMemory);
+            maxCpuCores = getVmMaxCpuCores(serviceOfferingVO, vmDescription, maxHostCpuCore);
+        }
+
+        virtualMachineTo.setRam(minMemory, maxMemory);
+        virtualMachineTo.setCpus(minCpuCores);
+        virtualMachineTo.setVcpuMaxLimit(maxCpuCores);
+    }
+
+    protected Pair<Long, Integer> getHostMaxMemoryAndCpuCores(HostVO host, VirtualMachine virtualMachine, String vmDescription){
+        Long maxHostMemory = Long.MAX_VALUE;
+        Integer maxHostCpuCore = Integer.MAX_VALUE;
 
-        // Determine the VM's OS description
-        GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId());
-        to.setOs(guestOS.getDisplayName());
-        HostVO host = _hostDao.findById(vm.getVirtualMachine().getHostId());
-        GuestOSHypervisorVO guestOsMapping = null;
         if (host != null) {
-            guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());
+            return new Pair<>(host.getTotalMemory(), host.getCpus());
         }
-        if (guestOsMapping == null || host == null) {
-            to.setPlatformEmulator(guestOS.getDisplayName() == null ? "Other" : guestOS.getDisplayName());
+
+        Long lastHostId = virtualMachine.getLastHostId();
+        s_logger.info(String.format("%s is not running; therefore, we use the last host [%s] that the VM was running on to derive the unconstrained service offering max CPU and memory.", vmDescription, lastHostId));
+
+        HostVO lastHost = lastHostId == null ? null : _hostDao.findById(lastHostId);
+        if (lastHost != null) {
+            maxHostMemory = lastHost.getTotalMemory();
+            maxHostCpuCore = lastHost.getCpus();
+            s_logger.debug(String.format("Retrieved memory and cpu max values {\"memory\": %s, \"cpu\": %s} from %s last %s.", maxHostMemory, maxHostCpuCore, vmDescription, lastHost.toString()));
         } else {
-            to.setPlatformEmulator(guestOsMapping.getGuestOsName());
+            s_logger.warn(String.format("%s host [%s] and last host [%s] are null. Using 'Long.MAX_VALUE' [%s] and 'Integer.MAX_VALUE' [%s] as max memory and cpu cores.", vmDescription, virtualMachine.getHostId(), lastHostId, maxHostMemory, maxHostCpuCore));
         }
 
-        return to;
+        return new Pair<>(maxHostMemory, maxHostCpuCore);
+    }
+
+    protected Long getVmMaxMemory(ServiceOfferingVO serviceOfferingVO, String vmDescription, Long maxHostMemory) {
+        String serviceOfferingDescription = serviceOfferingVO.toString();
+
+        Long maxMemory;
+        Integer customOfferingMaxMemory = NumberUtils.createInteger(serviceOfferingVO.getDetail(ApiConstants.MAX_MEMORY));
+        Integer maxMemoryConfig = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.value();
+        if (customOfferingMaxMemory != null) {
+            s_logger.debug(String.format("Using 'Custom unconstrained' %s max memory value [%sMb] as %s memory.", serviceOfferingDescription, customOfferingMaxMemory, vmDescription));

Review comment:
       Thanks for the review.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r654289864



##########
File path: engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4684,11 +4683,15 @@ private VMInstanceVO orchestrateReConfigureVm(String vmUuid, ServiceOffering old
                 new ScaleVmCommand(vm.getInstanceName(), newServiceOffering.getCpu(), minSpeed,
                         newServiceOffering.getSpeed(), minMemory * 1024L * 1024L, newServiceOffering.getRamSize() * 1024L * 1024L, newServiceOffering.getLimitCpuUse());
 
-        Long dstHostId = vm.getHostId();
+        scaleVmCommand.getVirtualMachine().setId(vm.getId());
+        scaleVmCommand.getVirtualMachine().setUuid(vm.getUuid());
+        scaleVmCommand.getVirtualMachine().setType(vm.getType());
 
-        if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
-            HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
-            Map<String, String> details = hvGuru.getClusterSettings(vm.getId());
+        final Long dstHostId = vm.getHostId();
+        if(vm.getHypervisorType().equals(HypervisorType.VMware)) {
+            final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
+            Map<String, String> details = null;
+            details = hvGuru.getClusterSettings(vm.getId());

Review comment:
       why this change?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-896574659


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902577108


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 952


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-869959428


   @GutoVeronezi, the code LGTM, but I didn't test it with the latest changes


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-897339657


   <b>Trillian test result (tid-1601)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 48404 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1601-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_diagnostics.py
   Intermittent failure detected: /marvin/tests/smoke/test_domain_service_offerings.py
   Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
   Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
   Intermittent failure detected: /marvin/tests/smoke/test_primary_storage.py
   Intermittent failure detected: /marvin/tests/smoke/test_service_offerings.py
   Intermittent failure detected: /marvin/tests/smoke/test_snapshots.py
   Intermittent failure detected: /marvin/tests/smoke/test_usage.py
   Intermittent failure detected: /marvin/tests/smoke/test_vm_deployment_planner.py
   Intermittent failure detected: /marvin/tests/smoke/test_vm_life_cycle.py
   Intermittent failure detected: /marvin/tests/smoke/test_volumes.py
   Smoke tests completed. 80 look OK, 8 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_01_add_primary_storage_disabled_host | `Error` | 0.14 | test_primary_storage.py
   test_03_migration_options_storage_tags | `Error` | 0.01 | test_primary_storage.py
   test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 | `Failure` | 448.37 | test_internal_lb.py
   test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 | `Failure` | 542.12 | test_internal_lb.py
   test_01_invalid_upgrade_kubernetes_cluster | `Failure` | 670.76 | test_kubernetes_clusters.py
   test_02_deploy_and_upgrade_kubernetes_cluster | `Failure` | 78.29 | test_kubernetes_clusters.py
   test_03_deploy_and_scale_kubernetes_cluster | `Failure` | 66.51 | test_kubernetes_clusters.py
   test_04_basic_lifecycle_kubernetes_cluster | `Failure` | 59.36 | test_kubernetes_clusters.py
   test_05_delete_kubernetes_cluster | `Failure` | 76.61 | test_kubernetes_clusters.py
   test_07_deploy_kubernetes_ha_cluster | `Failure` | 0.21 | test_kubernetes_clusters.py
   test_08_deploy_and_upgrade_kubernetes_ha_cluster | `Failure` | 3.22 | test_kubernetes_clusters.py
   test_09_delete_kubernetes_ha_cluster | `Failure` | 0.24 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 173.56 | test_kubernetes_clusters.py
   ContextSuite context=TestCpuCapServiceOfferings>:setup | `Error` | 0.00 | test_service_offerings.py
   test_02_list_snapshots_with_removed_data_store | `Error` | 0.27 | test_snapshots.py
   ContextSuite context=TestSnapshotUsage>:setup | `Error` | 150.40 | test_usage.py
   test_01_deploy_vm_on_specific_host | `Error` | 1.13 | test_vm_deployment_planner.py
   test_04_deploy_vm_on_host_override_pod_and_cluster | `Error` | 1.65 | test_vm_deployment_planner.py
   test_01_secure_vm_migration | `Error` | 85.92 | test_vm_life_cycle.py
   test_02_unsecure_vm_migration | `Error` | 225.57 | test_vm_life_cycle.py
   test_04_nonsecured_to_secured_vm_migration | `Error` | 148.24 | test_vm_life_cycle.py
   test_08_migrate_vm | `Error` | 0.05 | test_vm_life_cycle.py
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866083495


   @GutoVeronezi, I understand your point, but I think this is kind of a problem for the users. I mean that the update of the virtual machine to support dynamic scaling has to be disabled in this case, or when scaling such a VM, the `maxMemory` tag has to be set to the Domain (I don't know if this option is possible)
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r616227462



##########
File path: utils/src/main/java/org/apache/cloudstack/utils/bytescale/ByteScaleUtils.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cloudstack.utils.bytescale;
+
+/**
+ * This class provides a facility to convert bytes through his scales (b, Kib, Kb, Mib, Mb...).
+ *
+ */
+public class ByteScaleUtils {
+
+    public static final int KiB = 1024;

Review comment:
       Actually it is a good point, thanks for the review.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-869959428


   @GutoVeronezi, the code LGTM, but I didn't test it with the latest changes


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland merged pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland merged pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878


   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865058066


   @GabrielBrascher could you review this?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-864138359


   Packaging result: :heavy_check_mark: centos7 :heavy_check_mark: centos8 :heavy_check_mark: debian. SL-JID 297


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-886519208


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian. SL-JID 651


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GabrielBrascher edited a comment on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GabrielBrascher edited a comment on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902160435


   Manual tests LGTM.
   I will "officially" approve when the license headers are updated :+1: .


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-896869179


   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-847034219


   Can anyone review this?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GabrielBrascher commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r692366004



##########
File path: plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtScaleVmCommandWrapperTest.java
##########
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.

Review comment:
       Please check the **Copyright**

##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtScaleVmCommandWrapper.java
##########
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.

Review comment:
       Please check the **Copyright**

##########
File path: plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVmMemoryDeviceDefTest.java
##########
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.

Review comment:
       Please check the Copyright

##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVmMemoryDeviceDef.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.

Review comment:
       @GutoVeronezi I think that these source code headers need to be updated removing  **Copyright** as we discussed in another PR (sorry but I forgot which one xD)




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-885948198


   @DaanHoogland done, thanks!


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-884408740


   <b>Trillian test result (tid-1336)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 35550 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1336-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_vpc_vpn.py
   Smoke tests completed. 89 look OK, 0 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-896868997


   @blueorangutan test


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi edited a comment on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi edited a comment on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866379553


   > @GutoVeronezi, I understand your point, but I think this is kind of a problem for the users. I mean that the update of the virtual machine to support dynamic scaling has to be disabled in this case, or when scaling such a VM, the `maxMemory` tag has to be set to the Domain (I don't know if this option is possible)
   
   @slavkap  As we are changing the settings between deploy and scaling, it creates an inconsistency in the validations.    
   About manually adding the `maxMemory` tag at runtime, we would need to change/add some others definitions too, like numa cells in cpu; Also Libvirt do not allow to resize maximum memory on active domains.
   
   Do you have any suggestion about how we can solve this?
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865555942


   @GutoVeronezi, I've tested this with few use cases, and it works as expected. However, I've hit one problem, but not sure if it has to be fixed in this PR:
   - Create unconstrained service offering
   - disable `enable.dynamic.scale.vm`
   - Deploy VM with the new offering
   - enable `enable.dynamic.scale.vm`
   - update VM with `isdynamicallyscalable=true`
   - try to scale the VM 
   
   This error occurs 
   
   > 2021-06-22 07:46:02,730 WARN  [resource.wrapper.LibvirtScaleVmCommandWrapper] (agentRequest-Handler-5:null) (logid:8f9fc53e) Unable to scale com.cloud.agent.api.to.VirtualMachineTO@495dee84 memory to [2097152 KiB] and cpu cores to [4] due to [unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined].
   > org.libvirt.LibvirtException: unsupported configuration: cannot use/hotplug a memory device when domain 'maxMemory' is not defined
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-889726562


   @DaanHoogland, I've tested with the latest changes and it works as expected. I have only one suggestion, @GutoVeronezi, if you can add in VirtualMachineManagerImpl::reConfigureVM to check for RuntimeException.
   ```
   else if (jobResult instanceof RuntimeException) {
           throw (RuntimeException)jobResult;
   }
   ```
   
   Someone on the mailing list complained that CS does not send proper error msgs to the users in some cases.
   
   > {
   >   "accountid": "b3e15775-77f4-11eb-a307-02000a0201ba",
   >   "cmd": "org.apache.cloudstack.api.command.admin.vm.ScaleVMCmdByAdmin",
   >   "completed": "2021-07-30T10:42:43+0300",
   >   "created": "2021-07-30T10:42:42+0300",
   >   "jobid": "71c2811b-76b9-47fc-b678-e8b737c46d2e",
   >   "jobprocstatus": 0,
   >   "jobresult": {
   >     "errorcode": 530,
   >     "errortext": "Unhandled exception"
   >   },
   >   "jobresultcode": 530,
   >   "jobresulttype": "object",
   >   "jobstatus": 2,
   >   "userid": "b3e18e06-77f4-11eb-a307-02000a0201ba"
   > }
   
   > {
   >   "accountid": "b3e15775-77f4-11eb-a307-02000a0201ba",
   >   "cmd": "org.apache.cloudstack.api.command.admin.vm.ScaleVMCmdByAdmin",
   >   "completed": "2021-07-30T11:10:21+0300",
   >   "created": "2021-07-30T11:10:20+0300",
   >   "jobid": "b4a42cfb-c37f-43ad-aac1-d07a0800bf06",
   >   "jobprocstatus": 0,
   >   "jobresult": {
   >     "errorcode": 530,
   >     "errortext": "Unable to scale vm due to Unable to scale VM {id: \"244\", name: \"i-2-244-VM\", uuid: \"917bea0b-78a2-4923-b0a6-8a056c641cc8\", type: \"User\"} memory to [4194304 KiB] and CPU cores to [4] due to [The VM {id: \"244\", name: \"i-2-244-VM\", uuid: \"917bea0b-78a2-4923-b0a6-8a056c641cc8\", type: \"User\"} is not prepared for dynamic scaling. To be prepared, the VM must be deployed with a dynamic service offering, VM dynamic scale enabled and global setting \"enable.dynamic.scale.vm\" as \"true\". If you changed one of these settings after deploying the VM, consider stopping and starting it again to prepared it to dynamic scaling.]."
   >   },
   >   "jobresultcode": 530,
   >   "jobresulttype": "object",
   >   "jobstatus": 2,
   >   "userid": "b3e18e06-77f4-11eb-a307-02000a0201ba"
   > }


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-866626361


   @GutoVeronezi, the only safe option I can think of at the moment is when we update the virtual machine to support dynamic scaling, which is to tell the user that the VM should be stopped (for KVM hypervisors). At the start of the VM, the `maxMemory` will be set.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-815127887


   @wido We already have the API `resizeVolume`, which is designed to scale the root disk as well as data disks, and it works with VMs in `stopped` or `running` states.
   
   This API `scaleVirtualMachine` was first designed to scale computing resources (`memory`, `cpuNumber` and `cpuSpeed`). I think we should not mix these two concepts here.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi closed pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi closed pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-896606191


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian. SL-JID 838


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] slavkap commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
slavkap commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r656343134



##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtScaleVmCommandWrapper.java
##########
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cloud.hypervisor.kvm.resource.wrapper;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.ScaleVmAnswer;
+import com.cloud.agent.api.ScaleVmCommand;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
+import com.cloud.hypervisor.kvm.resource.LibvirtVmMemoryDeviceDef;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import org.apache.cloudstack.utils.bytescale.ByteScaleUtils;
+import org.libvirt.Connect;
+import org.libvirt.Domain;
+import org.libvirt.LibvirtException;
+
+@ResourceWrapper(handles = ScaleVmCommand.class)
+public final class LibvirtScaleVmCommandWrapper extends CommandWrapper<ScaleVmCommand, Answer, LibvirtComputingResource> {
+
+    @Override
+    public Answer execute(ScaleVmCommand command, LibvirtComputingResource libvirtComputingResource) {
+        VirtualMachineTO vmSpec = command.getVirtualMachine();
+        String vmName = vmSpec.getName();
+        Connect conn = null;
+
+        long newMemory = ByteScaleUtils.bytesToKib(vmSpec.getMaxRam());
+        int newVcpus = vmSpec.getCpus();
+        String vmDefinition = vmSpec.toString();
+        String scalingDetails = String.format("%s memory to [%s KiB] and cpu cores to [%s]", vmDefinition, newMemory, newVcpus);
+
+        try {
+            LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
+
+            conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName);
+            Domain dm = conn.domainLookupByName(vmName);
+
+            long currentMemory = LibvirtComputingResource.getDomainMemory(dm);
+            long runningVcpus = libvirtComputingResource.countDomainRunningVcpus(dm);
+            long memoryToAttach = newMemory - currentMemory;
+
+            logger.debug(String.format("Scaling %s.", scalingDetails));
+
+            if (memoryToAttach > 0) {
+                String memoryDevice = new LibvirtVmMemoryDeviceDef(newMemory - LibvirtComputingResource.getDomainMemory(dm)).toString();

Review comment:
       ```suggestion
                   String memoryDevice = new LibvirtVmMemoryDeviceDef(memoryToAttach).toString();
   ```
   I think that there is no need to retrieve the domain's memory again




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-883436987


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian. SL-JID 603


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-869826422


   @slavkap @DaanHoogland I pushed new changes refactoring `LibvirtScaleVmCommandWrapper` and covering it with better unit tests.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] wido commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
wido commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-815021158


   In this PR: https://github.com/apache/cloudstack/pull/4341
   
   The functionality was added that the rootDiskSize can be configured in an Offering.
   
   When we scale the VM we should also scale the rootdisk's size if that is bigger in the new offering.
   
   This PR does not seem to do that. We probably want that added as well.
   
   I really like this PR though. Very much welcome!


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902556963


   @DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902611837


   @blueorangutan test


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-869826422


   @slavkap @DaanHoogland I pushed new changes refactoring `LibvirtScaleVmCommandWrapper` and covering it with better unit tests.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-865331519


   <b>Trillian test result (tid-1024)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 45222 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4878-t1024-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
   Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
   Intermittent failure detected: /marvin/tests/smoke/test_outofbandmanagement.py
   Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
   Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
   Smoke tests completed. 85 look OK, 3 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 | `Failure` | 546.86 | test_internal_lb.py
   test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true | `Failure` | 336.76 | test_routers_network_ops.py
   test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false | `Failure` | 339.90 | test_routers_network_ops.py
   test_02_redundant_VPC_default_routes | `Failure` | 1177.75 | test_vpc_redundant.py
   test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers | `Failure` | 499.68 | test_vpc_redundant.py
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#discussion_r656626552



##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtScaleVmCommandWrapper.java
##########
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2021 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cloud.hypervisor.kvm.resource.wrapper;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.ScaleVmAnswer;
+import com.cloud.agent.api.ScaleVmCommand;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
+import com.cloud.hypervisor.kvm.resource.LibvirtVmMemoryDeviceDef;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import org.apache.cloudstack.utils.bytescale.ByteScaleUtils;
+import org.libvirt.Connect;
+import org.libvirt.Domain;
+import org.libvirt.LibvirtException;
+
+@ResourceWrapper(handles = ScaleVmCommand.class)
+public final class LibvirtScaleVmCommandWrapper extends CommandWrapper<ScaleVmCommand, Answer, LibvirtComputingResource> {
+
+    @Override
+    public Answer execute(ScaleVmCommand command, LibvirtComputingResource libvirtComputingResource) {
+        VirtualMachineTO vmSpec = command.getVirtualMachine();
+        String vmName = vmSpec.getName();
+        Connect conn = null;
+
+        long newMemory = ByteScaleUtils.bytesToKib(vmSpec.getMaxRam());
+        int newVcpus = vmSpec.getCpus();
+        String vmDefinition = vmSpec.toString();
+        String scalingDetails = String.format("%s memory to [%s KiB] and cpu cores to [%s]", vmDefinition, newMemory, newVcpus);
+
+        try {
+            LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
+
+            conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName);
+            Domain dm = conn.domainLookupByName(vmName);
+
+            long currentMemory = LibvirtComputingResource.getDomainMemory(dm);
+            long runningVcpus = libvirtComputingResource.countDomainRunningVcpus(dm);
+            long memoryToAttach = newMemory - currentMemory;
+
+            logger.debug(String.format("Scaling %s.", scalingDetails));
+
+            if (memoryToAttach > 0) {
+                String memoryDevice = new LibvirtVmMemoryDeviceDef(newMemory - LibvirtComputingResource.getDomainMemory(dm)).toString();

Review comment:
       @slavkap done, thanks for the review.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-890047878


   > @DaanHoogland, I've tested with the latest changes and it works as expected. I have only one suggestion, @GutoVeronezi, if you can add in VirtualMachineManagerImpl::reConfigureVM to check for RuntimeException.
   > 
   > ```
   > else if (jobResult instanceof RuntimeException) {
   >         throw (RuntimeException)jobResult;
   > }
   > ```
   > ...
   
   @slavkap Nice catch, done! Thanks.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4878: Support vm dynamic scaling with kvm

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4878:
URL: https://github.com/apache/cloudstack/pull/4878#issuecomment-902612005


   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org