Skip to content

Commit a6d1729

Browse files
Don't remove MDM IPs when other pools of same ScaleIO/PowerFlex cluster are connected
1 parent b2bae8e commit a6d1729

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface StoragePoolHostDao extends GenericDao<StoragePoolHostVO, Long>
3030

3131
public StoragePoolHostVO findByPoolHost(long poolId, long hostId);
3232

33+
List<StoragePoolHostVO> findByLocalPath(String path);
34+
3335
List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus);
3436

3537
List<Long> findHostsConnectedToPools(List<Long> poolIds);

engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo
4545
protected final SearchBuilder<StoragePoolHostVO> PoolSearch;
4646
protected final SearchBuilder<StoragePoolHostVO> HostSearch;
4747
protected final SearchBuilder<StoragePoolHostVO> PoolHostSearch;
48+
protected final SearchBuilder<StoragePoolHostVO> LocalPathSearch;
4849

4950
protected SearchBuilder<StoragePoolHostVO> poolNotInClusterSearch;
5051

@@ -77,6 +78,9 @@ public StoragePoolHostDaoImpl() {
7778
PoolHostSearch.and("host_id", PoolHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
7879
PoolHostSearch.done();
7980

81+
LocalPathSearch = createSearchBuilder();
82+
LocalPathSearch.and("local_path", LocalPathSearch.entity().getLocalPath(), SearchCriteria.Op.EQ);
83+
LocalPathSearch.done();
8084
}
8185

8286
@PostConstruct
@@ -117,6 +121,13 @@ public StoragePoolHostVO findByPoolHost(long poolId, long hostId) {
117121
return findOneIncludingRemovedBy(sc);
118122
}
119123

124+
@Override
125+
public List<StoragePoolHostVO> findByLocalPath(String path) {
126+
SearchCriteria<StoragePoolHostVO> sc = LocalPathSearch.create();
127+
sc.setParameters("local_path", path);
128+
return listBy(sc);
129+
}
130+
120131
@Override
121132
public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
122133
TransactionLegacy txn = TransactionLegacy.currentTxn();

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ public boolean unprepareSDC(Host host, DataStore dataStore) {
297297
}
298298

299299
if (!canUnprepareSDC(host, dataStore)) {
300-
logger.debug("Cannot unprepare SDC, there might be some volumes mapped to the SDC that belongs to the storage pools of PowerFlex storage cluster");
300+
logger.debug("Cannot unprepare SDC, there might be other connected pools of same PowerFlex storage cluster," +
301+
"or some volumes mapped to the SDC that belongs to any of the storage pools of the PowerFlex storage cluster");
301302
return false;
302303
}
303304

@@ -358,6 +359,12 @@ public boolean canUnprepareSDC(Host host, DataStore dataStore) {
358359
return false;
359360
}
360361

362+
List<StoragePoolHostVO> poolHostVOsBySdc = storagePoolHostDao.findByLocalPath(sdcId);
363+
if (CollectionUtils.isNotEmpty(poolHostVOsBySdc) && poolHostVOsBySdc.size() > 1) {
364+
LOGGER.debug(String.format("There are other connected pools with the same SDC of the host %s, shouldn't unprepare SDC", host));
365+
return false;
366+
}
367+
361368
try {
362369
final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
363370
return client.listVolumesMappedToSdc(sdcId).isEmpty();

0 commit comments

Comments
 (0)