mirror of https://github.com/apache/cloudstack.git
Fix enable primary datastore maintenance command seriliaztion on it
This commit is contained in:
parent
38b9618e4b
commit
19745ea049
|
|
@ -27,6 +27,8 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
|
|
@ -222,6 +224,13 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
|
|||
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster && storageMgr.isStoragePoolDatastoreClusterParent(pool)) {
|
||||
return false;
|
||||
}
|
||||
// Skip the storage pool whose parent datastore cluster is not in UP state.
|
||||
if (pool.getParent() != 0L) {
|
||||
StoragePoolVO datastoreCluster = storagePoolDao.findById(pool.getParent());
|
||||
if (datastoreCluster == null || (datastoreCluster != null && datastoreCluster.getStatus() != StoragePoolStatus.Up)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
boolean isStoragePoolStoragepolicyComplaince = storageMgr.isStoragePoolComplaintWithStoragePolicy(requestVolumes, pool);
|
||||
|
|
|
|||
|
|
@ -1541,6 +1541,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
DataStore store = _dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary);
|
||||
|
||||
if (primaryStorage.getPoolType() == StoragePoolType.DatastoreCluster) {
|
||||
if (primaryStorage.getStatus() == StoragePoolStatus.PrepareForMaintenance) {
|
||||
throw new CloudRuntimeException(String.format("There is already a job running for preparation for maintenance of the storage pool %s", primaryStorage.getUuid()));
|
||||
}
|
||||
handlePrepareDatastoreCluserMaintenance(lifeCycle, primaryStorageId);
|
||||
}
|
||||
lifeCycle.maintain(store);
|
||||
|
|
@ -1549,6 +1552,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
}
|
||||
|
||||
private void handlePrepareDatastoreCluserMaintenance(DataStoreLifeCycle lifeCycle, Long primaryStorageId) {
|
||||
StoragePoolVO datastoreCluster = _storagePoolDao.findById(primaryStorageId);
|
||||
datastoreCluster.setStatus(StoragePoolStatus.PrepareForMaintenance);
|
||||
_storagePoolDao.update(datastoreCluster.getId(), datastoreCluster);
|
||||
|
||||
// Before preparing the datastorecluster to maintenance mode, the storagepools in the datastore cluster needs to put in maintenance
|
||||
List<StoragePoolVO> childDatastores = _storagePoolDao.listChildStoragePoolsInDatastoreCluster(primaryStorageId);
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
|
|
@ -1611,6 +1618,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
|
||||
DataStore store = _dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary);
|
||||
if (primaryStorage.getPoolType() == StoragePoolType.DatastoreCluster) {
|
||||
primaryStorage.setStatus(StoragePoolStatus.Up);
|
||||
_storagePoolDao.update(primaryStorage.getId(), primaryStorage);
|
||||
//FR41 need to handle when one of the primary stores is unable to cancel the maintenance mode
|
||||
List<StoragePoolVO> childDatastores = _storagePoolDao.listChildStoragePoolsInDatastoreCluster(primaryStorageId);
|
||||
for (StoragePoolVO childDatastore : childDatastores) {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
|||
spes = primaryDataStoreDao.listBy(pool.getDataCenterId(), pool.getPodId(), pool.getClusterId(), ScopeType.CLUSTER);
|
||||
}
|
||||
for (StoragePoolVO sp : spes) {
|
||||
if (sp.getParent() != pool.getParent()) { // If Datastore cluster is tried to prepare for maintenance then child storage pools are also kept in PrepareForMaintenance mode
|
||||
if (sp.getParent() != pool.getParent() && sp.getId() != pool.getParent()) { // If Datastore cluster is tried to prepare for maintenance then child storage pools are also kept in PrepareForMaintenance mode
|
||||
if (sp.getStatus() == StoragePoolStatus.PrepareForMaintenance) {
|
||||
throw new CloudRuntimeException("Only one storage pool in a cluster can be in PrepareForMaintenance mode, " + sp.getId() +
|
||||
" is already in PrepareForMaintenance mode ");
|
||||
|
|
@ -321,7 +321,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
|||
}
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("ModifyStoragePool add secceeded");
|
||||
s_logger.debug("ModifyStoragePool add succeeded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue