mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11014:
1. if there is no storage pool, don't try to start system VM 2. not use "consoleproxy.restart" as other meaning status 11014: resolved fixed
This commit is contained in:
parent
7e1fc2ca1a
commit
455f9f642c
@ -92,9 +92,12 @@ import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.servlet.ConsoleProxyServlet;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.user.Account;
|
||||
@ -190,6 +193,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
ServiceOfferingDao _offeringDao;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
StoragePoolDao _storagePoolDao;
|
||||
|
||||
private ConsoleProxyListener _listener;
|
||||
|
||||
@ -1556,10 +1561,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
return false;
|
||||
}
|
||||
|
||||
// config var for consoleproxy.restart check
|
||||
String restart = _configDao.getValue("consoleproxy.restart");
|
||||
if (restart != null && restart.equalsIgnoreCase("false")) {
|
||||
s_logger.debug("Capacity scan disabled purposefully, consoleproxy.restart = false. This happens when the primarystorage is in maintenance mode");
|
||||
List<StoragePoolVO> upPools = _storagePoolDao.listByStatus(StoragePoolStatus.Up);
|
||||
if (upPools == null || upPools.size() == 0 ) {
|
||||
s_logger.debug("Skip capacity scan due to there is no Primary Storage UPintenance mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -4228,9 +4228,9 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public long getPsMaintenanceCount(long podId) {
|
||||
List<StoragePoolVO> poolsInTransition = new ArrayList<StoragePoolVO>();
|
||||
poolsInTransition.addAll(_poolDao.listPoolsByStatus(StoragePoolStatus.Maintenance));
|
||||
poolsInTransition.addAll(_poolDao.listPoolsByStatus(StoragePoolStatus.PrepareForMaintenance));
|
||||
poolsInTransition.addAll(_poolDao.listPoolsByStatus(StoragePoolStatus.ErrorInMaintenance));
|
||||
poolsInTransition.addAll(_poolDao.listByStatus(StoragePoolStatus.Maintenance));
|
||||
poolsInTransition.addAll(_poolDao.listByStatus(StoragePoolStatus.PrepareForMaintenance));
|
||||
poolsInTransition.addAll(_poolDao.listByStatus(StoragePoolStatus.ErrorInMaintenance));
|
||||
|
||||
return poolsInTransition.size();
|
||||
}
|
||||
|
||||
@ -1274,11 +1274,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
} else {
|
||||
createCapacityEntry(pool);
|
||||
}
|
||||
|
||||
// ensures cpvm is restarted even if the existing pools in system are in maintenance, hence flag below was hitherto in
|
||||
// false state
|
||||
_configMgr.updateConfiguration(UserContext.current().getCallerUserId(), "consoleproxy.restart", "true");
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
@ -2064,7 +2059,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
// check to see if other ps exist
|
||||
// if they do, then we can migrate over the system vms to them
|
||||
// if they dont, then just stop all vms on this one
|
||||
List<StoragePoolVO> upPools = _storagePoolDao.listPoolsByStatus(StoragePoolStatus.Up);
|
||||
List<StoragePoolVO> upPools = _storagePoolDao.listByStatus(StoragePoolStatus.Up);
|
||||
|
||||
if (upPools == null || upPools.size() == 0) {
|
||||
restart = false;
|
||||
@ -2114,11 +2109,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
// if the instance is of type consoleproxy, call the console proxy
|
||||
if (vmInstance.getType().equals(VirtualMachine.Type.ConsoleProxy)) {
|
||||
// make sure it is not restarted again, update config to set flag to false
|
||||
if (!restart) {
|
||||
_configMgr.updateConfiguration(userId, "consoleproxy.restart", "false");
|
||||
}
|
||||
|
||||
// call the consoleproxymanager
|
||||
ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(vmInstance.getId());
|
||||
if (!_vmMgr.advanceStop(consoleProxy, true, user, account)) {
|
||||
@ -2132,8 +2122,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
// Restore config val for consoleproxy.restart to true
|
||||
_configMgr.updateConfiguration(userId, "consoleproxy.restart", "true");
|
||||
|
||||
if (_vmMgr.advanceStart(consoleProxy, null, user, account) == null) {
|
||||
String errorMsg = "There was an error starting the console proxy id: " + vmInstance.getId() + " on another storage pool, cannot enable primary storage maintenance";
|
||||
@ -2366,20 +2354,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restore config val for consoleproxy.restart to true
|
||||
try {
|
||||
_configMgr.updateConfiguration(userId, "consoleproxy.restart", "true");
|
||||
} catch (InvalidParameterValueException e) {
|
||||
String msg = "Error changing consoleproxy.restart back to false at end of cancel maintenance:";
|
||||
s_logger.warn(msg, e);
|
||||
throw new ExecutionException(msg);
|
||||
} catch (CloudRuntimeException e) {
|
||||
String msg = "Error changing consoleproxy.restart back to false at end of cancel maintenance:";
|
||||
s_logger.warn(msg, e);
|
||||
throw new ExecutionException(msg);
|
||||
}
|
||||
|
||||
return primaryStorage;
|
||||
} catch (Exception e) {
|
||||
setPoolStateToError(primaryStorage);
|
||||
|
||||
@ -103,6 +103,5 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
||||
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listPoolsByStatus(StoragePoolStatus status);
|
||||
|
||||
List<StoragePoolVO> listByStatus(StoragePoolStatus status);
|
||||
}
|
||||
|
||||
@ -46,16 +46,10 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Local(value={StoragePoolDao.class}) @DB(txn=false)
|
||||
public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements StoragePoolDao {
|
||||
protected final SearchBuilder<StoragePoolVO> NameSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> UUIDSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DatacenterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> HostSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> HostPathDcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> HostPathDcSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> StatusSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> MaintenanceCountSearch;
|
||||
|
||||
|
||||
@ -66,17 +60,15 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
|
||||
|
||||
protected StoragePoolDaoImpl() {
|
||||
NameSearch = createSearchBuilder();
|
||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
NameSearch.done();
|
||||
|
||||
UUIDSearch = createSearchBuilder();
|
||||
UUIDSearch.and("uuid", UUIDSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
UUIDSearch.done();
|
||||
|
||||
DatacenterSearch = createSearchBuilder();
|
||||
DatacenterSearch.and("datacenterId", DatacenterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DatacenterSearch.done();
|
||||
AllFieldSearch = createSearchBuilder();
|
||||
AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("status",AllFieldSearch.entity().getStatus(),SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
|
||||
AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
|
||||
AllFieldSearch.done();
|
||||
|
||||
DcPodSearch = createSearchBuilder();
|
||||
DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
@ -100,28 +92,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
DeleteLvmSearch.cp();
|
||||
DeleteLvmSearch.done();
|
||||
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("host", HostSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
StatusSearch = createSearchBuilder();
|
||||
StatusSearch.and("status",StatusSearch.entity().getStatus(),SearchCriteria.Op.EQ);
|
||||
StatusSearch.done();
|
||||
|
||||
HostPathDcPodSearch = createSearchBuilder();
|
||||
HostPathDcPodSearch.and("hostAddress", HostPathDcPodSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
HostPathDcPodSearch.and("path", HostPathDcPodSearch.entity().getPath(), SearchCriteria.Op.EQ);
|
||||
HostPathDcPodSearch.and("datacenterId", HostPathDcPodSearch.entity().getDataCenterId(), Op.EQ);
|
||||
HostPathDcPodSearch.and("podId", HostPathDcPodSearch.entity().getPodId(), Op.EQ);
|
||||
HostPathDcPodSearch.and("uuid", HostPathDcPodSearch.entity().getUuid(), Op.EQ);
|
||||
HostPathDcPodSearch.done();
|
||||
|
||||
HostPathDcSearch = createSearchBuilder();
|
||||
HostPathDcSearch.and("hostAddress", HostPathDcSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
|
||||
HostPathDcSearch.and("path", HostPathDcSearch.entity().getPath(), SearchCriteria.Op.EQ);
|
||||
HostPathDcSearch.done();
|
||||
DeleteLvmSearch.done();
|
||||
|
||||
MaintenanceCountSearch = createSearchBuilder(Long.class);
|
||||
MaintenanceCountSearch.and("pool", MaintenanceCountSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
@ -134,7 +105,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolByName(String name) {
|
||||
SearchCriteria<StoragePoolVO> sc = NameSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
@ -142,7 +113,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public StoragePoolVO findPoolByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = UUIDSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
@ -151,7 +122,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = UUIDSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return listBy(sc);
|
||||
}
|
||||
@ -159,7 +130,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = DatacenterSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
return listBy(sc);
|
||||
}
|
||||
@ -183,21 +154,21 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
|
||||
SearchCriteria<StoragePoolVO> sc = HostSearch.create();
|
||||
sc.setParameters("host", hostFqdnOrIp);
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", hostFqdnOrIp);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolsByStatus(StoragePoolStatus status){
|
||||
SearchCriteria<StoragePoolVO> sc = StatusSearch.create();
|
||||
public List<StoragePoolVO> listByStatus(StoragePoolStatus status){
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("status", status);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = HostPathDcPodSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
sc.setParameters("datacenterId", datacenterId);
|
||||
@ -226,7 +197,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
|
||||
SearchCriteria<StoragePoolVO> sc = HostPathDcSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("hostAddress", host);
|
||||
sc.setParameters("path", path);
|
||||
|
||||
@ -235,7 +206,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
public StoragePoolVO listById(Integer id)
|
||||
{
|
||||
SearchCriteria<StoragePoolVO> sc = HostSearch.create();
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("id", id);
|
||||
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
|
||||
@ -2371,7 +2371,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
// check if we have available pools for vm deployment
|
||||
List<StoragePoolVO> availablePools = _storagePoolDao.listPoolsByStatus(StoragePoolStatus.Up);
|
||||
List<StoragePoolVO> availablePools = _storagePoolDao.listByStatus(StoragePoolStatus.Up);
|
||||
|
||||
if (availablePools == null || availablePools.size() < 1) {
|
||||
throw new StorageUnavailableException("There are no available pools in the UP state for vm deployment", -1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user