Skip to content

Commit 89d2b17

Browse files
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 b143ddc commit 89d2b17

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
@@ -294,6 +294,8 @@ static Boolean getFullCloneConfiguration(Long storeId) {
294294

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

297+
void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer);
298+
297299
CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId);
298300

299301
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
@@ -448,8 +448,8 @@ public boolean maintain(DataStore dataStore) {
448448

449449
@Override
450450
public boolean cancelMaintain(DataStore store) {
451-
storagePoolAutmation.cancelMaintain(store);
452451
dataStoreHelper.cancelMaintain(store);
452+
storagePoolAutmation.cancelMaintain(store);
453453
return true;
454454
}
455455

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

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

26892689
}
26902690

2691-
private void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) {
2691+
@Override
2692+
public void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer) {
26922693
StoragePoolHostVO poolHost = _storagePoolHostDao.findByPoolHost(pool.getId(), hostId);
26932694
if (poolHost == null) {
26942695
poolHost = new StoragePoolHostVO(pool.getId(), hostId, mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
@@ -2698,8 +2699,10 @@ private void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, Modi
26982699
}
26992700

27002701
StoragePoolVO poolVO = _storagePoolDao.findById(pool.getId());
2701-
poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes());
2702-
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
2702+
if (!Storage.StoragePoolType.StorPool.equals(poolVO.getPoolType())) {
2703+
poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes());
2704+
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
2705+
}
27032706

27042707
_storagePoolDao.update(pool.getId(), poolVO);
27052708
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ public boolean cancelMaintain(DataStore store) {
346346
if (logger.isDebugEnabled()) {
347347
logger.debug("ModifyStoragePool add succeeded");
348348
}
349+
storageManager.updateStoragePoolHostVOAndBytes(pool, host.getId(), (ModifyStoragePoolAnswer) answer);
349350
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
350351
logger.debug("Started synchronising datastore cluster storage pool {} with vCenter", pool);
351352
storageManager.syncDatastoreClusterStoragePool(pool.getId(), ((ModifyStoragePoolAnswer) answer).getDatastoreClusterChildren(), host.getId());

0 commit comments

Comments
 (0)