CLOUDSTACK-4664: [ZWPS] High delay to start a stopped VM which has ROOT/DATA volumes migrated to Second Zone wide primary Storage(More than 10 mins)
Changes: - DeploymentPlanningManager needs to reuse the zone wide primary storage pool when VM's volume is READY Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f3be68a8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f3be68a8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f3be68a8 Branch: refs/heads/4.2-forward Commit: f3be68a83301837d14243fec8eba9927565b928e Parents: f4e4be0 Author: Prachi Damle <[email protected]> Authored: Fri Sep 13 14:37:00 2013 -0700 Committer: Prachi Damle <[email protected]> Committed: Fri Sep 13 16:55:41 2013 -0700 ---------------------------------------------------------------------- .../deploy/DeploymentPlanningManagerImpl.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f3be68a8/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index b73aad2..2ca58c6 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -37,6 +37,7 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.messagebus.MessageBus; @@ -78,6 +79,7 @@ import com.cloud.org.Cluster; import com.cloud.org.Grouping; import com.cloud.resource.ResourceState; import com.cloud.storage.DiskOfferingVO; +import com.cloud.storage.ScopeType; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolHostVO; @@ -1076,11 +1078,24 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy if (!pool.isInMaintenance()) { if (!avoid.shouldAvoid(pool)) { long exstPoolDcId = pool.getDataCenterId(); - long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1; long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1; + boolean canReusePool = false; if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) { + canReusePool = true; + } else if (plan.getDataCenterId() == exstPoolDcId) { + DataStore dataStore = this.dataStoreMgr.getPrimaryDataStore(pool.getId()); + if (dataStore != null && dataStore.getScope() != null + && dataStore.getScope().getScopeType() == ScopeType.ZONE) { + canReusePool = true; + } + } else { + s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume"); + canReusePool = false; + } + + if (canReusePool) { s_logger.debug("Planner need not allocate a pool for this volume since its READY"); suitablePools.add(pool); suitableVolumeStoragePools.put(toBeCreated, suitablePools); @@ -1088,8 +1103,6 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy readyAndReusedVolumes.add(toBeCreated); } continue; - } else { - s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume"); } } else { s_logger.debug("Pool of the volume is in avoid set, need to reallocate a pool for this volume");
