Search in sources :

Example 6 with EventResult

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;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConnectHostToStoragePoolServersParameters(org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) CommandContext(org.ovirt.engine.core.bll.context.CommandContext)

Example 7 with EventResult

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;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDSError(org.ovirt.engine.core.common.errors.VDSError) List(java.util.List) ArrayList(java.util.ArrayList) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Example 8 with EventResult

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;
    });
}
Also used : EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event)

Example 9 with EventResult

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;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDS(org.ovirt.engine.core.common.businessentities.VDS) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 10 with EventResult

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));
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) EngineException(org.ovirt.engine.core.common.errors.EngineException) Event(org.ovirt.engine.core.common.eventqueue.Event)

Aggregations

EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)11 Event (org.ovirt.engine.core.common.eventqueue.Event)6 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)4 ArrayList (java.util.ArrayList)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Guid (org.ovirt.engine.core.compat.Guid)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VdsSpmIdMap (org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1