Skip to content

Commit f451a81

Browse files
committed
CLOUDSTACK-4859:Add global config to disable storage migration during HA
1 parent ac02987 commit f451a81

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,16 @@ private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool>
944944
}
945945
throw new CloudRuntimeException("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner");
946946
} else {
947-
if (s_logger.isDebugEnabled()) {
948-
s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner");
947+
//Check if storage migration is enabled in config
948+
if (StorageHAMigrationEnabled.value()) {
949+
if (s_logger.isDebugEnabled()) {
950+
s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner");
951+
}
952+
VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool);
953+
tasks.add(task);
954+
} else {
955+
throw new CloudRuntimeException("Cannot migrate volumes. Volume Migration is disabled");
949956
}
950-
VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool);
951-
tasks.add(task);
952957
}
953958
} else {
954959
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
@@ -1106,9 +1111,16 @@ public boolean canVmRestartOnAnotherServer(long vmId) {
11061111
"If true, will recreate system vm root disk whenever starting system vm",
11071112
true);
11081113

1114+
public static final ConfigKey<Boolean> StorageHAMigrationEnabled = new ConfigKey<Boolean>(Boolean.class,
1115+
"enable.ha.storage.migration",
1116+
"Storage",
1117+
"true",
1118+
"Enable/disable storage migration across primary storage during HA",
1119+
true);
1120+
11091121
@Override
11101122
public ConfigKey<?>[] getConfigKeys() {
1111-
return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize};
1123+
return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize, StorageHAMigrationEnabled};
11121124
}
11131125

11141126
@Override
@@ -1164,6 +1176,7 @@ public String getStoragePoolOfVolume(long volumeId) {
11641176
return dataStoreMgr.getPrimaryDataStore(vol.getPoolId()).getUuid();
11651177
}
11661178

1179+
@Override
11671180
public void updateVolumeDiskChain(long volumeId, String path, String chainInfo) {
11681181
VolumeVO vol = _volsDao.findById(volumeId);
11691182
boolean needUpdate = false;
@@ -1174,7 +1187,7 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo)
11741187
needUpdate = true;
11751188

11761189
if(needUpdate) {
1177-
s_logger.info("Update volume disk chain info. vol: " + vol.getId() + ", " + vol.getPath() + " -> " + path
1190+
s_logger.info("Update volume disk chain info. vol: " + vol.getId() + ", " + vol.getPath() + " -> " + path
11781191
+ ", " + vol.getChainInfo() + " -> " + chainInfo);
11791192
vol.setPath(path);
11801193
vol.setChainInfo(chainInfo);

server/src/com/cloud/configuration/Config.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public enum Config {
7979
CreatePrivateTemplateFromSnapshotWait("Storage", UserVmManager.class, Integer.class, "create.private.template.from.snapshot.wait", "10800", "In second, timeout for CreatePrivateTemplateFromSnapshotCommand", null),
8080
BackupSnapshotWait(
8181
"Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "21600", "In second, timeout for BackupSnapshotCommand", null),
82-
82+
HAStorageMigration("Storage", ManagementServer.class, Boolean.class, "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA", null),
83+
8384
// Network
8485
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", null),
8586
NetworkLBHaproxyStatsUri("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.uri","/admin?stats","Load Balancer(haproxy) uri.",null),

setup/db/db/schema-420to421.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222

2323
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.multipart.enabled', 'true', 'enable s3 multipart upload');
2424

25+
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT', 'management-server', "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA");
26+

0 commit comments

Comments
 (0)