Skip to content

Commit c55bc0b

Browse files
Harikrishna Patnalakishankavala
authored andcommitted
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
1 parent 3a5401f commit c55bc0b

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

api/src/com/cloud/vm/VirtualMachineProfile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static class Param {
4141
public static final Param ReProgramGuestNetworks = new Param("RestartNetwork");
4242
public static final Param PxeSeverType = new Param("PxeSeverType");
4343
public static final Param HaTag = new Param("HaTag");
44+
public static final Param HaOperation = new Param("HaOperation");
4445

4546
private String name;
4647

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ private static class VolumeTask {
10781078
}
10791079
}
10801080

1081-
private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool> destVols) throws StorageUnavailableException {
1081+
private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool> destVols, VirtualMachineProfile vm) throws StorageUnavailableException {
10821082
boolean recreate = RecreatableSystemVmEnabled.value();
10831083
List<VolumeTask> tasks = new ArrayList<VolumeTask>();
10841084
for (VolumeVO vol : vols) {
@@ -1118,7 +1118,14 @@ private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool>
11181118
throw new CloudRuntimeException("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner");
11191119
} else {
11201120
//Check if storage migration is enabled in config
1121-
if (StorageHAMigrationEnabled.value()) {
1121+
Boolean isHAOperation = (Boolean)vm.getParameter(VirtualMachineProfile.Param.HaOperation);
1122+
Boolean storageMigrationEnabled = true;
1123+
if (isHAOperation != null && isHAOperation) {
1124+
storageMigrationEnabled = StorageHAMigrationEnabled.value();
1125+
} else {
1126+
storageMigrationEnabled = StorageMigrationEnabled.value();
1127+
}
1128+
if(storageMigrationEnabled){
11221129
if (s_logger.isDebugEnabled()) {
11231130
s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner");
11241131
}
@@ -1276,7 +1283,7 @@ public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws Sto
12761283
s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm);
12771284
}
12781285

1279-
List<VolumeTask> tasks = getTasks(vols, dest.getStorageForDisks());
1286+
List<VolumeTask> tasks = getTasks(vols, dest.getStorageForDisks(), vm);
12801287
Volume vol = null;
12811288
StoragePool pool = null;
12821289
for (VolumeTask task : tasks) {
@@ -1327,6 +1334,9 @@ public boolean canVmRestartOnAnotherServer(long vmId) {
13271334
public static final ConfigKey<Boolean> StorageHAMigrationEnabled = new ConfigKey<Boolean>(Boolean.class, "enable.ha.storage.migration", "Storage", "true",
13281335
"Enable/disable storage migration across primary storage during HA", true);
13291336

1337+
public static final ConfigKey<Boolean> StorageMigrationEnabled = new ConfigKey<Boolean>(Boolean.class, "enable.storage.migration", "Storage", "true",
1338+
"Enable/disable storage migration across primary storage", true);
1339+
13301340
@Override
13311341
public ConfigKey<?>[] getConfigKeys() {
13321342
return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize, StorageHAMigrationEnabled, CustomDiskOfferingMaxSize, CustomDiskOfferingMinSize};

server/src/com/cloud/ha/HighAvailabilityManagerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ protected Long restart(HaWorkVO work) {
578578
if (_haTag != null) {
579579
params.put(VirtualMachineProfile.Param.HaTag, _haTag);
580580
}
581+
WorkType wt = work.getWorkType();
582+
if (wt.equals(WorkType.HA)) {
583+
params.put(VirtualMachineProfile.Param.HaOperation, true);
584+
}
581585

582586
try{
583587
// First try starting the vm with its original planner, if it doesn't succeed send HAPlanner as its an emergency.

0 commit comments

Comments
 (0)