use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method initializeStorage.
private boolean initializeStorage() {
boolean returnValue = false;
// connect any storage
if (getStoragePool() == null || StoragePoolStatus.Uninitialized == getStoragePool().getStatus() || StoragePoolStatus.Maintenance == getStoragePool().getStatus()) {
returnValue = true;
connectPoolSucceeded = true;
} else {
ConnectHostToStoragePoolServersParameters params = new ConnectHostToStoragePoolServersParameters(getStoragePool(), getVds());
CommandContext ctx = cloneContext();
ctx.getExecutionContext().setJobRequired(false);
runInternalAction(ActionType.ConnectHostToStoragePoolServers, params, ctx);
EventResult connectResult = connectHostToPool();
if (connectResult != null) {
returnValue = connectResult.isSuccess();
problematicDomains = (List<StorageDomainStatic>) connectResult.getResultData();
}
connectPoolSucceeded = returnValue;
}
return returnValue;
}
use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method runConnectHostToPoolEvent.
private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) {
EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
StoragePool storagePool = storagePoolDao.get(storagePoolId);
StorageDomain masterDomain = storageDomainDao.getStorageDomains(storagePoolId, StorageDomainType.Master).get(0);
List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == StorageDomainStatus.Inactive || masterDomain.getStatus() == StorageDomainStatus.Unknown;
VDSError error = null;
try {
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomain.getId(), storagePoolIsoMap));
if (!vdsReturnValue.getSucceeded()) {
error = vdsReturnValue.getVdsError();
}
} catch (EngineException e) {
error = e.getVdsError();
}
if (error != null) {
if (error.getCode() != EngineError.CannotConnectMultiplePools && masterDomainInactiveOrUnknown) {
log.info("Could not connect host '{}' to pool '{}', as the master domain is in inactive/unknown" + " status - not failing the operation", vds.getName(), storagePool.getName());
} else {
log.error("Could not connect host '{}' to pool '{}': {}", vds.getName(), storagePool.getName(), error.getMessage());
result.setSuccess(false);
}
}
if (result.isSuccess()) {
Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown, storagePool);
result.setSuccess(vdsStatsResults.getFirst());
if (!result.isSuccess()) {
result.setResultData(vdsStatsResults.getSecond());
auditLogDirector.log(this, AuditLogType.VDS_STORAGE_VDS_STATS_FAILED);
}
}
return result;
}
use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.
the class IrsProxy method addDomainData.
public void addDomainData(final Guid domainId) {
getEventQueue().submitEventAsync(new Event(storagePoolId, domainId, null, EventType.DOMAINFAILOVER, ""), () -> {
EventResult result = null;
if (domainsInProblem.containsKey(domainId)) {
log.info("starting processDomainRecovery for domain '{}'.", getDomainIdTuple(domainId));
result = processDomainRecovery(domainId);
}
timersMap.remove(domainId);
return result;
});
}
use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.
the class IrsProxy method processDomainRecovery.
private EventResult processDomainRecovery(final Guid domainId) {
EventResult result = null;
// build a list of all the hosts in status UP in
// Pool.
List<Guid> vdssInPool = new ArrayList<>();
// Note - this method is used as it returns only hosts from VIRT supported clusters
// (we use the domain monitoring results only from those clusters hosts).
// every change to it should be inspected carefully.
List<VDS> allVds = vdsDao.getAllForStoragePoolAndStatus(storagePoolId, null);
Map<Guid, VDS> vdsMap = new HashMap<>();
for (VDS tempVDS : allVds) {
vdsMap.put(tempVDS.getId(), tempVDS);
if (tempVDS.getStatus() == VDSStatus.Up) {
vdssInPool.add(tempVDS.getId());
}
}
// build a list of all the hosts that did not report
// on this domain as in problem.
// Mark the above list as hosts we suspect are in
// problem.
Set<Guid> hostsThatReportedDomainAsInProblem = domainsInProblem.get(domainId);
List<Guid> vdssInProblem = new ArrayList<>();
for (Guid tempVDSId : vdssInPool) {
if (!hostsThatReportedDomainAsInProblem.contains(tempVDSId)) {
vdssInProblem.add(tempVDSId);
}
}
// If not All the hosts in status UP reported on
// this domain as in problem. We assume the problem
// is with the hosts
// that did report on a problem with this domain.
// (and not a problem with the domain itself).
StorageDomainStatic storageDomain = storageDomainStaticDao.get(domainId);
String domainIdTuple = getDomainIdTuple(domainId);
List<Guid> nonOpVdss = new ArrayList<>();
if (vdssInProblem.size() > 0) {
if (storageDomain.getStorageDomainType() != StorageDomainType.ImportExport && storageDomain.getStorageDomainType() != StorageDomainType.ISO) {
// operational.
for (final Guid vdsId : domainsInProblem.get(domainId)) {
VDS vds = vdsMap.get(vdsId);
if (vds == null) {
log.warn("vds '{}' reported domain '{}' - as in problem but cannot find vds in db!!", vdsId, domainIdTuple);
} else if (vds.getStatus() == VDSStatus.Up) {
log.warn("vds '{}' reported domain '{}' as in problem, attempting to move the vds to status NonOperational", vds.getName(), domainIdTuple);
final Map<String, String> customLogValues = Collections.singletonMap("StorageDomainNames", storageDomain.getName());
ThreadPoolUtil.execute(() -> resourceManager.getEventListener().vdsNonOperational(vdsId, NonOperationalReason.STORAGE_DOMAIN_UNREACHABLE, true, domainId, customLogValues));
nonOpVdss.add(vdsId);
} else {
log.warn("vds '{}' reported domain '{}' as in problem, vds is in status '{}', no need to move to nonoperational", vds.getName(), domainIdTuple, vds.getStatus());
}
}
} else {
log.warn("Storage domain '{}' is not visible to one or more hosts. " + "Since the domain's type is '{}', hosts status will not be changed to non-operational", domainIdTuple, storageDomain.getStorageDomainType());
}
result = new EventResult(true, EventType.VDSSTORAGEPROBLEMS);
} else {
// Domain.
if (storageDomain.getStorageDomainType() != StorageDomainType.Master) {
log.error("Domain '{}' was reported by all hosts in status UP as problematic. Moving the domain to NonOperational.", domainIdTuple);
result = getEventListener().storageDomainNotOperational(domainId, storagePoolId);
} else {
log.warn("Domain '{}' was reported by all hosts in status UP as problematic. Not moving the domain to NonOperational because it is being reconstructed now.", domainIdTuple);
result = getEventListener().masterDomainNotOperational(domainId, storagePoolId, false, false);
}
}
// clear from cache of domainsInProblem
clearDomainFromCache(domainId, nonOpVdss);
return result;
}
use of org.ovirt.engine.core.common.eventqueue.EventResult in project ovirt-engine by oVirt.
the class RecoveryStoragePoolCommand method executeCommand.
@Override
protected void executeCommand() {
StorageDomain newMasterDomain = loadTargetedMasterDomain();
if (storageHelperDirector.getItem(newMasterDomain.getStorageType()).connectStorageToDomainByVdsId(newMasterDomain, getVds().getId())) {
getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getNewMasterDomainId(), null, EventType.RECOVERY, ""), () -> {
getParameters().setStorageDomainId(getMasterDomainIdFromDb());
StoragePoolIsoMap domainPoolMap = new StoragePoolIsoMap(getParameters().getNewMasterDomainId(), getParameters().getStoragePoolId(), StorageDomainStatus.Active);
storagePoolIsoMapDao.save(domainPoolMap);
getParameters().setVdsId(getVds().getId());
ActionReturnValue returnVal = runInternalAction(ActionType.ReconstructMasterDomain, getParameters(), cloneContextAndDetachFromParent());
boolean reconstructVerbExecuted = (returnVal.getActionReturnValue() != null) ? (Boolean) returnVal.getActionReturnValue() : false;
storagePoolDao.updateStatus(getStoragePool().getId(), StoragePoolStatus.NonResponsive);
if (!reconstructVerbExecuted) {
storagePoolIsoMapDao.remove(domainPoolMap.getId());
}
if (returnVal.getSucceeded()) {
updateStorageDomainFormatIfNeeded(loadTargetedMasterDomain());
}
setSucceeded(returnVal.getSucceeded());
return new EventResult(reconstructVerbExecuted, EventType.RECONSTRUCT);
});
} else {
getReturnValue().setFault(new EngineFault(new EngineException(EngineError.StorageServerConnectionError, "Failed to connect storage"), EngineError.StorageServerConnectionError));
}
}
Aggregations