From 9cf05dc842f3fb4649746ad536eca1855184e15b Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Thu, 11 Sep 2014 11:07:43 +0530 Subject: [PATCH] CLOUDSTACK-7534: ResetVM for VM with attached datadisk fails when enable.ha.storage.migration is false Separate global config to enable/disable Storage Migration during normal deployment Introduced a configuration parameter named enable.storage.migration (cherry picked from commit c55bc0b2d11be4820a24af426e23da3db54a0cb1) Signed-off-by: Rohit Yadav --- api/src/com/cloud/vm/VirtualMachineProfile.java | 1 + .../engine/orchestration/VolumeOrchestrator.java | 16 +++++++++++++--- .../cloud/ha/HighAvailabilityManagerImpl.java | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/vm/VirtualMachineProfile.java b/api/src/com/cloud/vm/VirtualMachineProfile.java index 29f31646321..d0fea49ae8d 100644 --- a/api/src/com/cloud/vm/VirtualMachineProfile.java +++ b/api/src/com/cloud/vm/VirtualMachineProfile.java @@ -41,6 +41,7 @@ public interface VirtualMachineProfile { public static final Param ReProgramGuestNetworks = new Param("RestartNetwork"); public static final Param PxeSeverType = new Param("PxeSeverType"); public static final Param HaTag = new Param("HaTag"); + public static final Param HaOperation = new Param("HaOperation"); private String name; diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index fd4883b1f7f..1a3c0b6dd86 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -1101,7 +1101,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } } - private List getTasks(List vols, Map destVols) throws StorageUnavailableException { + private List getTasks(List vols, Map destVols, VirtualMachineProfile vm) throws StorageUnavailableException { boolean recreate = RecreatableSystemVmEnabled.value(); List tasks = new ArrayList(); for (VolumeVO vol : vols) { @@ -1141,7 +1141,14 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati throw new CloudRuntimeException("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner"); } else { //Check if storage migration is enabled in config - if (StorageHAMigrationEnabled.value()) { + Boolean isHAOperation = (Boolean)vm.getParameter(VirtualMachineProfile.Param.HaOperation); + Boolean storageMigrationEnabled = true; + if (isHAOperation != null && isHAOperation) { + storageMigrationEnabled = StorageHAMigrationEnabled.value(); + } else { + storageMigrationEnabled = StorageMigrationEnabled.value(); + } + if(storageMigrationEnabled){ if (s_logger.isDebugEnabled()) { s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner"); } @@ -1299,7 +1306,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm); } - List tasks = getTasks(vols, dest.getStorageForDisks()); + List tasks = getTasks(vols, dest.getStorageForDisks(), vm); Volume vol = null; StoragePool pool = null; for (VolumeTask task : tasks) { @@ -1350,6 +1357,9 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati public static final ConfigKey StorageHAMigrationEnabled = new ConfigKey(Boolean.class, "enable.ha.storage.migration", "Storage", "true", "Enable/disable storage migration across primary storage during HA", true); + public static final ConfigKey StorageMigrationEnabled = new ConfigKey(Boolean.class, "enable.storage.migration", "Storage", "true", + "Enable/disable storage migration across primary storage", true); + @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {RecreatableSystemVmEnabled, MaxVolumeSize, StorageHAMigrationEnabled, CustomDiskOfferingMaxSize, CustomDiskOfferingMinSize}; diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java index a305543ca91..a278750d896 100755 --- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -578,6 +578,10 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai if (_haTag != null) { params.put(VirtualMachineProfile.Param.HaTag, _haTag); } + WorkType wt = work.getWorkType(); + if (wt.equals(WorkType.HA)) { + params.put(VirtualMachineProfile.Param.HaOperation, true); + } try{ // First try starting the vm with its original planner, if it doesn't succeed send HAPlanner as its an emergency.