Skip to content

Commit 8be5b61

Browse files
weizhouapachedhslove
authored andcommitted
storage: change storage pool to Up state when cancel storage migration (apache#11773)
* storage: change storage pool to Up state when cancel storage migration * Update 11773: connect host to shared pool after cancelling storage migration * Update 11773: update db only * Update 11773: skip capacity update for storpool
1 parent eae9b3e commit 8be5b61

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ static Boolean getFullCloneConfiguration(Long storeId) {
302302

303303
Answer sendToPool(StoragePool pool, long[] hostIdsToTryFirst, Command cmd) throws StorageUnavailableException;
304304

305+
void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer);
306+
305307
CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId);
306308

307309
CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ public boolean maintain(DataStore dataStore) {
476476

477477
@Override
478478
public boolean cancelMaintain(DataStore store) {
479-
storagePoolAutmation.cancelMaintain(store);
480479
dataStoreHelper.cancelMaintain(store);
480+
storagePoolAutmation.cancelMaintain(store);
481481
return true;
482482
}
483483

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,8 @@ private void handleRemoveChildStoragePoolFromDatastoreCluster(Set<String> childD
30803080

30813081
}
30823082

3083-
private void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) {
3083+
@Override
3084+
public void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) {
30843085
StoragePoolHostVO poolHost = _storagePoolHostDao.findByPoolHost(pool.getId(), hostId);
30853086
if (poolHost == null) {
30863087
poolHost = new StoragePoolHostVO(pool.getId(), hostId, mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
@@ -3090,8 +3091,10 @@ private void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, Modi
30903091
}
30913092

30923093
StoragePoolVO poolVO = _storagePoolDao.findById(pool.getId());
3093-
poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes());
3094-
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
3094+
if (!Storage.StoragePoolType.StorPool.equals(poolVO.getPoolType())) {
3095+
poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes());
3096+
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
3097+
}
30953098

30963099
_storagePoolDao.update(pool.getId(), poolVO);
30973100
}

server/src/main/java/com/cloud/storage/StoragePoolAutomationImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ public boolean cancelMaintain(DataStore store, Map<String,String> details) {
363363
if (logger.isDebugEnabled()) {
364364
logger.debug("ModifyStoragePool add succeeded");
365365
}
366+
storageManager.updateStoragePoolHostVOAndBytes(pool, host.getId(), (ModifyStoragePoolAnswer) answer);
366367
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
367368
logger.debug("Started synchronising datastore cluster storage pool {} with vCenter", pool);
368369
storageManager.syncDatastoreClusterStoragePool(pool.getId(), ((ModifyStoragePoolAnswer) answer).getDatastoreClusterChildren(), host.getId());

0 commit comments

Comments
 (0)