DaanHoogland commented on a change in pull request #4722:
URL: https://github.com/apache/cloudstack/pull/4722#discussion_r617267935
##########
File path: server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
##########
@@ -167,8 +179,13 @@ protected void
addServiceOfferingExtraConfiguration(ServiceOffering offering, Vi
protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile
vmProfile) {
ServiceOffering offering =
_serviceOfferingDao.findById(vmProfile.getId(),
vmProfile.getServiceOfferingId());
VirtualMachine vm = vmProfile.getVirtualMachine();
- Long minMemory = (long)(offering.getRamSize() /
vmProfile.getMemoryOvercommitRatio());
- int minspeed = (int)(offering.getSpeed() /
vmProfile.getCpuOvercommitRatio());
+ HostVO host = hostDao.findById(vm.getHostId());
+
+ boolean divideMemoryByOverprovisioning =
VM_MIN_MEMORY_EQUALS_MEMORY_DIVIDED_BY_MEM_OVERPROVISIONING_FACTOR.valueIn(host.getClusterId());
+ boolean divideCpuByOverprovisioning =
VM_MIN_CPU_SPEED_EQUALS_CPU_SPEED_DIVIDED_BY_CPU_OVERPROVISIONING_FACTOR.valueIn(host.getClusterId());
+
Review comment:
```suggestion
boolean divideMemoryByOverprovisioning =
VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor.valueIn(host.getClusterId());
boolean divideCpuByOverprovisioning =
VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor.valueIn(host.getClusterId());
```
##########
File path: server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
##########
@@ -301,4 +318,15 @@ public boolean attachRestoredVolumeToVirtualMachine(long
zoneId, String location
public List<Command> finalizeMigrate(VirtualMachine vm, Map<Volume,
StoragePool> volumeToPool) {
return null;
}
+
+ @Override
+ public String getConfigComponentName() {
+ return HypervisorGuruBase.class.getSimpleName();
+ }
+
+ @Override
+ public ConfigKey<?>[] getConfigKeys() {
+ return new ConfigKey<?>[]
{VM_MIN_MEMORY_EQUALS_MEMORY_DIVIDED_BY_MEM_OVERPROVISIONING_FACTOR,
VM_MIN_CPU_SPEED_EQUALS_CPU_SPEED_DIVIDED_BY_CPU_OVERPROVISIONING_FACTOR };
Review comment:
```suggestion
return new ConfigKey<?>[]
{VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor,
VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor };
```
##########
File path: server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
##########
@@ -85,6 +89,14 @@
private ServiceOfferingDao _serviceOfferingDao;
@Inject
private NetworkDetailsDao networkDetailsDao;
+ @Inject
+ private HostDao hostDao;
+
+ public static ConfigKey<Boolean>
VM_MIN_MEMORY_EQUALS_MEMORY_DIVIDED_BY_MEM_OVERPROVISIONING_FACTOR = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"vm.min.memory.equals.memory.divided.by.mem.overprovisioning.factor", "true",
Review comment:
```suggestion
public static ConfigKey<Boolean>
VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"vm.min.memory.equals.memory.divided.by.mem.overprovisioning.factor", "true",
```
##########
File path: server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java
##########
@@ -85,6 +89,14 @@
private ServiceOfferingDao _serviceOfferingDao;
@Inject
private NetworkDetailsDao networkDetailsDao;
+ @Inject
+ private HostDao hostDao;
+
+ public static ConfigKey<Boolean>
VM_MIN_MEMORY_EQUALS_MEMORY_DIVIDED_BY_MEM_OVERPROVISIONING_FACTOR = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"vm.min.memory.equals.memory.divided.by.mem.overprovisioning.factor", "true",
+ "If we set this to 'true', a minimum memory (memory/
mem.overprovisioning.factor) will be set to the VM, independent of using a
scalable service offering or not.", true, ConfigKey.Scope.Cluster);
+
+ public static ConfigKey<Boolean>
VM_MIN_CPU_SPEED_EQUALS_CPU_SPEED_DIVIDED_BY_CPU_OVERPROVISIONING_FACTOR = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"vm.min.cpu.speed.equals.cpu.speed.divided.by.cpu.overprovisioning.factor",
"true",
Review comment:
```suggestion
public static ConfigKey<Boolean>
VmMinCpuSpeedEqualsCpuSpeedDividedByCpuOverprovisioningFactor = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"vm.min.cpu.speed.equals.cpu.speed.divided.by.cpu.overprovisioning.factor",
"true",
```
##########
File path:
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4564,18 +4574,23 @@ private VMInstanceVO orchestrateReConfigureVm(final
String vmUuid, final Service
_capacityMgr.allocateVmCapacity(vm, false); // lock the new
capacity
}
- final Answer reconfigureAnswer = _agentMgr.send(vm.getHostId(),
reconfigureCmd);
- if (reconfigureAnswer == null || !reconfigureAnswer.getResult()) {
- s_logger.error("Unable to scale vm due to " +
(reconfigureAnswer == null ? "" : reconfigureAnswer.getDetails()));
- throw new CloudRuntimeException("Unable to scale vm due to " +
(reconfigureAnswer == null ? "" : reconfigureAnswer.getDetails()));
+ Answer scaleVmAnswer = _agentMgr.send(vm.getHostId(),
scaleVmCommand);
+ if (scaleVmAnswer == null || !scaleVmAnswer.getResult()) {
+ String msg = String.format("Unable to scale %s due to [%s].",
vm.toString(), (scaleVmAnswer == null ? "" : scaleVmAnswer.getDetails()));
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
}
if (vm.getType().equals(VirtualMachine.Type.User)) {
_userVmMgr.generateUsageEvent(vm, vm.isDisplayVm(),
EventTypes.EVENT_VM_DYNAMIC_SCALE);
}
success = true;
- } catch (final OperationTimedoutException e) {
- throw new AgentUnavailableException("Operation timed out on
reconfiguring " + vm, dstHostId);
- } catch (final AgentUnavailableException e) {
+ } catch (OperationTimedoutException e) {
+ String msg = String.format("Unable to scale %s due to [%s].",
vm.toString(), e.getMessage());
+ s_logger.error(msg, e);
+ throw new AgentUnavailableException(msg, dstHostId);
+ } catch (AgentUnavailableException e) {
+ String msg = String.format("Unable to scale %s due to [%s].",
vm.toString(), e.getMessage());
+ s_logger.error(msg, e);
throw e;
} finally {
Review comment:
log, handle or rethrow, pick one i'd say @GutoVeronezi Why do you print
the stack and rethrow?
--
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:
[email protected]