use of org.ovirt.engine.core.common.businessentities.SpmStatusResult in project ovirt-engine by oVirt.
the class IrsProxy method startSpm.
private SpmStatusResult startSpm(final StoragePool storagePool, VDS selectedVds, int prevId, String lver, int vdsSpmIdToFence) {
storagePool.setStatus(StoragePoolStatus.Contend);
storagePool.setSpmVdsId(selectedVds.getId());
TransactionSupport.executeInNewTransaction(() -> {
storagePoolDao.update(storagePool);
return null;
});
log.info("starting spm on vds '{}', storage pool '{}', prevId '{}', LVER '{}'", selectedVds.getName(), storagePool.getName(), prevId, lver);
SpmStatusResult spmStatus = (SpmStatusResult) resourceManager.runVdsCommand(VDSCommandType.SpmStart, new SpmStartVDSCommandParameters(selectedVds.getId(), storagePoolId, prevId, lver, storagePool.getRecoveryMode(), vdsSpmIdToFence != -1, storagePool.getStoragePoolFormatType())).getReturnValue();
if (spmStatus == null || spmStatus.getSpmStatus() != SpmStatus.SPM) {
getEventListener().storagePoolStatusChange(storagePool.getId(), StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_PROBLEMATIC, EngineError.ENGINE, TransactionScopeOption.RequiresNew);
if (spmStatus != null) {
TransactionSupport.executeInNewTransaction(() -> {
StoragePool pool = storagePoolDao.get(storagePool.getId());
pool.setSpmVdsId(null);
storagePoolDao.update(pool);
return null;
});
}
throw new IrsSpmStartFailedException();
}
return spmStatus;
}
use of org.ovirt.engine.core.common.businessentities.SpmStatusResult in project ovirt-engine by oVirt.
the class IrsProxy method proceedStoragePoolStats.
@SuppressWarnings("unchecked")
private void proceedStoragePoolStats(StoragePool storagePool) {
// ugly patch because vdsm doesnt check if host is spm on spm
// operations
VDSReturnValue result = null;
Guid curVdsId = currentVdsId;
if (curVdsId != null) {
result = resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(curVdsId, storagePoolId));
}
if (result == null || !result.getSucceeded() || (result.getSucceeded() && ((SpmStatusResult) result.getReturnValue()).getSpmStatus() != SpmStatus.SPM)) {
// update pool status to problematic until fence will happen
if (storagePool.getStatus() != StoragePoolStatus.NonResponsive && storagePool.getStatus() != StoragePoolStatus.NotOperational) {
if (result != null && result.getVdsError() != null) {
updateStoragePoolStatus(storagePoolId, StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_PROBLEMATIC_WITH_ERROR, result.getVdsError().getCode());
} else {
updateStoragePoolStatus(storagePoolId, StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_PROBLEMATIC, EngineError.ENGINE);
}
}
// then cause failover with attempts
if (result != null && !(result.getExceptionObject() instanceof VDSNetworkException)) {
HashMap<Guid, AsyncTaskStatus> tasksList = (HashMap<Guid, AsyncTaskStatus>) resourceManager.runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(curVdsId)).getReturnValue();
boolean allTasksFinished = true;
if (tasksList != null) {
for (AsyncTaskStatus taskStatus : tasksList.values()) {
if (AsyncTaskStatusEnum.finished != taskStatus.getStatus()) {
allTasksFinished = false;
break;
}
}
}
if ((tasksList == null) || allTasksFinished) {
nullifyInternalProxies();
} else {
if (_errorAttempts < Config.<Integer>getValue(ConfigValues.SPMFailOverAttempts)) {
_errorAttempts++;
log.warn("failed getting spm status for pool '{}' ({}), attempt number: {}", storagePoolId, storagePool.getName(), _errorAttempts);
} else {
nullifyInternalProxies();
_errorAttempts = 0;
}
}
}
} else if (result.getSucceeded() && ((SpmStatusResult) result.getReturnValue()).getSpmStatus() == SpmStatus.SPM && (storagePool.getStatus() == StoragePoolStatus.NonResponsive || storagePool.getStatus() == StoragePoolStatus.Contend)) {
// if recovered from network exception set back to up
storagePoolDao.updateStatus(storagePool.getId(), StoragePoolStatus.Up);
storagePool.setStatus(StoragePoolStatus.Up);
getEventListener().storagePoolStatusChanged(storagePool.getId(), storagePool.getStatus());
}
List<StorageDomain> domainsInDb = storageDomainDao.getAllForStoragePool(storagePoolId);
GetStoragePoolInfoVDSCommandParameters tempVar = new GetStoragePoolInfoVDSCommandParameters(storagePoolId);
tempVar.setIgnoreFailoverLimit(true);
VDSReturnValue storagePoolInfoResult = resourceManager.runVdsCommand(VDSCommandType.GetStoragePoolInfo, tempVar);
if (storagePoolInfoResult.getSucceeded()) {
KeyValuePairCompat<StoragePool, List<StorageDomain>> data = (KeyValuePairCompat<StoragePool, List<StorageDomain>>) storagePoolInfoResult.getReturnValue();
int masterVersion = data.getKey().getMasterDomainVersion();
HashSet<Guid> domainsInVds = new HashSet<>();
List<StorageDomain> storageDomainsToSync = data.getValue().stream().peek(storageDomain -> domainsInVds.add(storageDomain.getId())).filter(storageDomain -> proceedStorageDomain(storageDomain, masterVersion, storagePool)).collect(Collectors.toList());
if (!storageDomainsToSync.isEmpty()) {
getEventListener().syncStorageDomainsLuns(getCurrentVdsId(), storageDomainsToSync.stream().map(StorageDomain::getId).collect(Collectors.toList()));
}
for (final StorageDomain domainInDb : domainsInDb) {
if (domainInDb.getStorageDomainType() != StorageDomainType.Master && domainInDb.getStatus() != StorageDomainStatus.Locked && !domainInDb.getStorageType().isCinderDomain() && !domainsInVds.contains(domainInDb.getId())) {
// domain not attached to pool anymore
storagePoolIsoMapDao.remove(new StoragePoolIsoMapId(domainInDb.getId(), storagePoolId));
}
}
}
domainsInMaintenanceCheck(domainsInDb, storagePool);
}
use of org.ovirt.engine.core.common.businessentities.SpmStatusResult in project ovirt-engine by oVirt.
the class SpmStartVDSCommand method executeVdsBrokerCommand.
@Override
protected void executeVdsBrokerCommand() {
result = getBroker().spmStart(getParameters().getStoragePoolId().toString(), getParameters().getPrevId(), getParameters().getPrevLVER(), getParameters().getRecoveryMode().getValue(), String.valueOf(getParameters().getSCSIFencing()).toLowerCase(), Config.getValue(ConfigValues.MaxNumberOfHostsInStoragePool), getParameters().getStoragePoolFormatType().getValue());
proceedProxyReturnValue();
Guid taskId = new Guid(result.uuid);
AsyncTaskStatus taskStatus;
log.info("spmStart polling started: taskId '{}'", taskId);
do {
// TODO: make configurable
ThreadUtils.sleep(1000L);
taskStatus = (AsyncTaskStatus) resourceManager.runVdsCommand(VDSCommandType.HSMGetTaskStatus, new HSMTaskGuidBaseVDSCommandParameters(vdsId, taskId)).getReturnValue();
log.debug("spmStart polling - task status: '{}'", taskStatus.getStatus());
} while (taskStatus.getStatus() != AsyncTaskStatusEnum.finished && taskStatus.getStatus() != AsyncTaskStatusEnum.unknown);
log.info("spmStart polling ended: taskId '{}' task status '{}'", taskId, taskStatus.getStatus());
if (!taskStatus.getTaskEndedSuccessfully()) {
log.error("Start SPM Task failed - result: '{}', message: {}", taskStatus.getResult(), taskStatus.getMessage());
}
SpmStatusResult spmStatus = (SpmStatusResult) resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(vdsId, getParameters().getStoragePoolId())).getReturnValue();
if (spmStatus != null) {
log.info("spmStart polling ended, spm status: {}", spmStatus.getSpmStatus());
} else {
log.error("spmStart polling ended, failed to get the spm status");
}
try {
resourceManager.runVdsCommand(VDSCommandType.HSMClearTask, new HSMTaskGuidBaseVDSCommandParameters(vdsId, taskId));
} catch (Exception e) {
log.error("Could not clear spmStart task '{}', continuing with SPM selection: {}", taskId, e.getMessage());
log.debug("Exception", e);
}
setReturnValue(spmStatus);
}
use of org.ovirt.engine.core.common.businessentities.SpmStatusResult in project ovirt-engine by oVirt.
the class SpmStatusVDSCommand method parseSpmStatusResult.
private SpmStatusResult parseSpmStatusResult() {
try {
SpmStatusResult statusResult = new SpmStatusResult();
statusResult.setSpmStatus((_result.spmStatus != null && _result.spmStatus.containsKey("spmStatus")) ? EnumUtils.valueOf(SpmStatus.class, _result.spmStatus.get("spmStatus").toString(), true) : SpmStatus.Unknown_Pool);
// if no lver and id put -5 hardcoded because of VDSM inconsistency
statusResult.setSpmLVER((_result.spmStatus != null && _result.spmStatus.containsKey("spmLver")) ? _result.spmStatus.get("spmLver").toString() : "-5");
statusResult.setSpmId((_result.spmStatus != null && _result.spmStatus.containsKey("spmId")) ? Integer.parseInt(_result.spmStatus.get("spmId").toString()) : -5);
return statusResult;
} catch (RuntimeException exp) {
log.error("Could not parse SPM Status: '{}'", _result.spmStatus);
throw exp;
}
}
use of org.ovirt.engine.core.common.businessentities.SpmStatusResult in project ovirt-engine by oVirt.
the class IrsProxy method failover.
public boolean failover() {
Guid vdsId = currentVdsId;
nullifyInternalProxies();
boolean performFailover = false;
if (vdsId != null) {
try {
VDSReturnValue statusResult = resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(vdsId, storagePoolId));
if (statusResult != null && statusResult.getSucceeded() && (((SpmStatusResult) statusResult.getReturnValue()).getSpmStatus() == SpmStatus.SPM || ((SpmStatusResult) statusResult.getReturnValue()).getSpmStatus() == SpmStatus.Contend)) {
performFailover = resourceManager.runVdsCommand(VDSCommandType.SpmStop, new SpmStopVDSCommandParameters(vdsId, storagePoolId)).getSucceeded();
} else {
performFailover = true;
}
} catch (Exception ex) {
// try to failover to another host if failed to get spm
// status or stop spm
// (in case currentVdsId has wrong id for some reason)
log.error("Could not get spm status on host '{}' for spmStop: {}", vdsId, ex.getMessage());
log.debug("Exception", ex);
performFailover = true;
}
}
if (performFailover) {
log.info("Irs placed on server '{}' failed. Proceed Failover", vdsId);
triedVdssList.add(vdsId);
return true;
} else {
log.error("IRS failover failed - can't allocate vds server");
return false;
}
}
Aggregations