This is an automated email from the ASF dual-hosted git repository.
bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new f2584bb CLOUDSTACK-9182: Some running VMs turned off on manual
migration when auto migration failed while host preparing for maintenance.
(#1252)
f2584bb is described below
commit f2584bb9e755ae296c0e05515363d6b3a5d3c71f
Author: sureshanaparti <[email protected]>
AuthorDate: Wed Sep 20 16:23:24 2017 +0530
CLOUDSTACK-9182: Some running VMs turned off on manual migration when auto
migration failed while host preparing for maintenance. (#1252)
Fix: Block VMOperations if Host in PrepareForMaintenance mode. VM
operations (Stop, Reboot, Destroy, Migrate to host) are not allowed when Host
in PrepareForMaintenance mode.
---
.../src/com/cloud/vm/VirtualMachineManagerImpl.java | 7 +++++++
server/src/com/cloud/vm/UserVmManagerImpl.java | 14 ++++++++++++++
2 files changed, 21 insertions(+)
diff --git
a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 638a000..f684cbf 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -159,6 +159,7 @@ import com.cloud.offering.DiskOfferingInfo;
import com.cloud.offering.ServiceOffering;
import com.cloud.org.Cluster;
import com.cloud.resource.ResourceManager;
+import com.cloud.resource.ResourceState;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
@@ -1531,6 +1532,12 @@ public class VirtualMachineManagerImpl extends
ManagerBase implements VirtualMac
_workDao.update(work.getId(), work);
}
return;
+ } else {
+ HostVO host = _hostDao.findById(hostId);
+ if (!cleanUpEvenIfUnableToStop && vm.getState() == State.Running
&& host.getResourceState() == ResourceState.PrepareForMaintenance) {
+ s_logger.debug("Host is in PrepareForMaintenance state - Stop
VM operation on the VM id: " + vm.getId() + " is not allowed");
+ throw new CloudRuntimeException("Stop VM operation on the VM
id: " + vm.getId() + " is not allowed as host is preparing for maintenance
mode");
+ }
}
final VirtualMachineGuru vmGuru = getVmGuru(vm);
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java
b/server/src/com/cloud/vm/UserVmManagerImpl.java
old mode 100755
new mode 100644
index 952b850..a19d4fa
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2636,6 +2636,8 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
_accountMgr.checkAccess(caller, null, true, vmInstance);
+ checkIfHostOfVMIsInPrepareForMaintenanceState(vmInstance.getHostId(),
vmId, "Reboot");
+
// If the VM is Volatile in nature, on reboot discard the VM's root
disk and create a new root disk for it: by calling restoreVM
long serviceOfferingId = vmInstance.getServiceOfferingId();
ServiceOfferingVO offering =
_serviceOfferingDao.findById(vmInstance.getId(), serviceOfferingId);
@@ -4845,6 +4847,8 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
throw ex;
}
+ checkIfHostOfVMIsInPrepareForMaintenanceState(vm.getHostId(), vmId,
"Migrate");
+
if(serviceOfferingDetailsDao.findDetail(vm.getServiceOfferingId(),
GPU.Keys.pciDevice.toString()) != null) {
throw new InvalidParameterValueException("Live Migration of GPU
enabled VM is not supported");
}
@@ -4938,6 +4942,16 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
}
}
+ private void checkIfHostOfVMIsInPrepareForMaintenanceState(Long hostId,
Long vmId, String operation) {
+ HostVO host = _hostDao.findById(hostId);
+ if (host.getResourceState() != ResourceState.PrepareForMaintenance) {
+ return;
+ }
+
+ s_logger.debug("Host is in PrepareForMaintenance state - " + operation
+ " VM operation on the VM id: " + vmId + " is not allowed");
+ throw new InvalidParameterValueException(operation + " VM operation on
the VM id: " + vmId + " is not allowed as host is preparing for maintenance
mode");
+ }
+
private Long accountOfDedicatedHost(HostVO host) {
long hostId = host.getId();
DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId);
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].