mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
engine/orchestration: Update overcommit ratio during live VM migration (#9178)
During live migration of a VM from between hosts having different cgroup versions (cgroupv2 & cgroup), overcommit ratio is ignored. This PR fixes the above issue.
This commit is contained in:
parent
fcfa371337
commit
351de5fabd
@ -190,6 +190,10 @@ public interface VirtualMachineProfile {
|
|||||||
|
|
||||||
Map<Param, Object> getParameters();
|
Map<Param, Object> getParameters();
|
||||||
|
|
||||||
|
void setCpuOvercommitRatio(Float cpuOvercommitRatio);
|
||||||
|
|
||||||
|
void setMemoryOvercommitRatio(Float memoryOvercommitRatio);
|
||||||
|
|
||||||
Float getCpuOvercommitRatio();
|
Float getCpuOvercommitRatio();
|
||||||
|
|
||||||
Float getMemoryOvercommitRatio();
|
Float getMemoryOvercommitRatio();
|
||||||
|
|||||||
@ -264,11 +264,13 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
|||||||
_offering = offering;
|
_offering = offering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setCpuOvercommitRatio(Float cpuOvercommitRatio) {
|
public void setCpuOvercommitRatio(Float cpuOvercommitRatio) {
|
||||||
this.cpuOvercommitRatio = cpuOvercommitRatio;
|
this.cpuOvercommitRatio = cpuOvercommitRatio;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMemoryOvercommitRatio(Float memoryOvercommitRatio) {
|
public void setMemoryOvercommitRatio(Float memoryOvercommitRatio) {
|
||||||
this.memoryOvercommitRatio = memoryOvercommitRatio;
|
this.memoryOvercommitRatio = memoryOvercommitRatio;
|
||||||
|
|
||||||
|
|||||||
@ -1235,21 +1235,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
|
|
||||||
long destHostId = dest.getHost().getId();
|
long destHostId = dest.getHost().getId();
|
||||||
vm.setPodIdToDeployIn(dest.getPod().getId());
|
vm.setPodIdToDeployIn(dest.getPod().getId());
|
||||||
final Long cluster_id = dest.getCluster().getId();
|
final Long clusterId = dest.getCluster().getId();
|
||||||
final ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
updateOverCommitRatioForVmProfile(vmProfile, clusterId);
|
||||||
final ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
|
||||||
|
|
||||||
if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO) == null &&
|
|
||||||
(Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f)) {
|
|
||||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, cluster_detail_cpu.getValue(), true);
|
|
||||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, cluster_detail_ram.getValue(), true);
|
|
||||||
} else if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO) != null) {
|
|
||||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, cluster_detail_cpu.getValue(), true);
|
|
||||||
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, cluster_detail_ram.getValue(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue()));
|
|
||||||
vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue()));
|
|
||||||
StartAnswer startAnswer = null;
|
StartAnswer startAnswer = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1264,7 +1252,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
resetVmNicsDeviceId(vm.getId());
|
resetVmNicsDeviceId(vm.getId());
|
||||||
_networkMgr.prepare(vmProfile, dest, ctx);
|
_networkMgr.prepare(vmProfile, dest, ctx);
|
||||||
if (vm.getHypervisorType() != HypervisorType.BareMetal) {
|
if (vm.getHypervisorType() != HypervisorType.BareMetal) {
|
||||||
checkAndAttemptMigrateVmAcrossCluster(vm, cluster_id, dest.getStorageForDisks());
|
checkAndAttemptMigrateVmAcrossCluster(vm, clusterId, dest.getStorageForDisks());
|
||||||
volumeMgr.prepare(vmProfile, dest);
|
volumeMgr.prepare(vmProfile, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,6 +1450,27 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateOverCommitRatioForVmProfile(VirtualMachineProfile vmProfile, long clusterId) {
|
||||||
|
final ClusterDetailsVO clusterDetailCpu = _clusterDetailsDao.findDetail(clusterId, VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
||||||
|
final ClusterDetailsVO clusterDetailRam = _clusterDetailsDao.findDetail(clusterId, VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
||||||
|
final float parsedClusterCpuDetailCpu = Float.parseFloat(clusterDetailCpu.getValue());
|
||||||
|
final float parsedClusterDetailRam = Float.parseFloat(clusterDetailRam.getValue());
|
||||||
|
UserVmDetailVO vmDetailCpu = userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO);
|
||||||
|
UserVmDetailVO vmDetailRam = userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO);
|
||||||
|
|
||||||
|
if ((vmDetailCpu == null && parsedClusterCpuDetailCpu > 1f) ||
|
||||||
|
(vmDetailCpu != null && Float.parseFloat(vmDetailCpu.getValue()) != parsedClusterCpuDetailCpu)) {
|
||||||
|
userVmDetailsDao.addDetail(vmProfile.getId(), VmDetailConstants.CPU_OVER_COMMIT_RATIO, clusterDetailCpu.getValue(), true);
|
||||||
|
}
|
||||||
|
if ((vmDetailRam == null && parsedClusterDetailRam > 1f) ||
|
||||||
|
(vmDetailRam != null && Float.parseFloat(vmDetailRam.getValue()) != parsedClusterDetailRam)) {
|
||||||
|
userVmDetailsDao.addDetail(vmProfile.getId(), VmDetailConstants.MEMORY_OVER_COMMIT_RATIO, clusterDetailRam.getValue(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
vmProfile.setCpuOvercommitRatio(Float.parseFloat(clusterDetailCpu.getValue()));
|
||||||
|
vmProfile.setMemoryOvercommitRatio(Float.parseFloat(clusterDetailRam.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting pod id to null can result in migration of Volumes across pods. This is not desirable for VMs which
|
* Setting pod id to null can result in migration of Volumes across pods. This is not desirable for VMs which
|
||||||
* have a volume in Ready state (happens when a VM is shutdown and started again).
|
* have a volume in Ready state (happens when a VM is shutdown and started again).
|
||||||
@ -2730,6 +2739,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
_networkMgr.prepareNicForMigration(profile, dest);
|
_networkMgr.prepareNicForMigration(profile, dest);
|
||||||
volumeMgr.prepareForMigration(profile, dest);
|
volumeMgr.prepareForMigration(profile, dest);
|
||||||
profile.setConfigDriveLabel(VmConfigDriveLabel.value());
|
profile.setConfigDriveLabel(VmConfigDriveLabel.value());
|
||||||
|
updateOverCommitRatioForVmProfile(profile, dest.getHost().getClusterId());
|
||||||
|
|
||||||
final VirtualMachineTO to = toVmTO(profile);
|
final VirtualMachineTO to = toVmTO(profile);
|
||||||
final PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand(to);
|
final PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand(to);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user