Updated Branches: refs/heads/4.2 059e4b2ae -> 10c550e8c
CLOUDSTACK-4157 Failure to add zone wide primary storage pool is leaving storage pool in database Signed-off-by: Sateesh Chodapuneedi <sate...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/10c550e8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/10c550e8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/10c550e8 Branch: refs/heads/4.2 Commit: 10c550e8caea8945951ab442bc3e424c2d34a376 Parents: 059e4b2 Author: Sateesh Chodapuneedi <sate...@apache.org> Authored: Wed Aug 7 17:40:57 2013 +0530 Committer: Sateesh Chodapuneedi <sate...@apache.org> Committed: Wed Aug 7 17:40:57 2013 +0530 ---------------------------------------------------------------------- .../lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/10c550e8/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java ---------------------------------------------------------------------- diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java index 2c8c871..3cc709a 100644 --- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java @@ -60,7 +60,6 @@ import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolAutomation; import com.cloud.storage.StoragePoolDiscoverer; import com.cloud.storage.StoragePoolHostVO; -import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.storage.dao.StoragePoolWorkDao; import com.cloud.storage.dao.VolumeDao; @@ -408,13 +407,21 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore @Override public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId()); + s_logger.debug("In createPool. Attaching the pool to each of the hosts."); + List<HostVO> poolHosts = new ArrayList<HostVO>(); for (HostVO host : hosts) { try { this.storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId()); + poolHosts.add(host); } catch (Exception e) { s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e); } } + if (poolHosts.isEmpty()) { + s_logger.warn("No host can access storage pool " + dataStore + " in this zone."); + primaryDataStoreDao.expunge(dataStore.getId()); + throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts."); + } this.dataStoreHelper.attachZone(dataStore, hypervisorType); return true; }