Skip to content

Commit 10c550e

Browse files
author
Sateesh Chodapuneedi
committed
CLOUDSTACK-4157 Failure to add zone wide primary storage pool is leaving storage pool in database
Signed-off-by: Sateesh Chodapuneedi <[email protected]>
1 parent 059e4b2 commit 10c550e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import com.cloud.storage.StoragePoolAutomation;
6161
import com.cloud.storage.StoragePoolDiscoverer;
6262
import com.cloud.storage.StoragePoolHostVO;
63-
import com.cloud.storage.StoragePoolStatus;
6463
import com.cloud.storage.dao.StoragePoolHostDao;
6564
import com.cloud.storage.dao.StoragePoolWorkDao;
6665
import com.cloud.storage.dao.VolumeDao;
@@ -408,13 +407,21 @@ public boolean attachCluster(DataStore store, ClusterScope scope) {
408407
@Override
409408
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
410409
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId());
410+
s_logger.debug("In createPool. Attaching the pool to each of the hosts.");
411+
List<HostVO> poolHosts = new ArrayList<HostVO>();
411412
for (HostVO host : hosts) {
412413
try {
413414
this.storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
415+
poolHosts.add(host);
414416
} catch (Exception e) {
415417
s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
416418
}
417419
}
420+
if (poolHosts.isEmpty()) {
421+
s_logger.warn("No host can access storage pool " + dataStore + " in this zone.");
422+
primaryDataStoreDao.expunge(dataStore.getId());
423+
throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts.");
424+
}
418425
this.dataStoreHelper.attachZone(dataStore, hypervisorType);
419426
return true;
420427
}

0 commit comments

Comments
 (0)