Search in sources :

Example 1 with SpmStatusResult

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;
}
Also used : SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) SpmStartVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStartVDSCommandParameters)

Example 2 with SpmStatusResult

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);
}
Also used : SpmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters) VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) StoragePoolDomainHelper(org.ovirt.engine.core.vdsbroker.storage.StoragePoolDomainHelper) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) StorageDomainDynamicDao(org.ovirt.engine.core.dao.StorageDomainDynamicDao) ScheduledFuture(java.util.concurrent.ScheduledFuture) LoggerFactory(org.slf4j.LoggerFactory) NonOperationalReason(org.ovirt.engine.core.common.businessentities.NonOperationalReason) EventType(org.ovirt.engine.core.common.eventqueue.EventType) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation) VdsDao(org.ovirt.engine.core.dao.VdsDao) KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) Map(java.util.Map) Event(org.ovirt.engine.core.common.eventqueue.Event) StoragePoolDao(org.ovirt.engine.core.dao.StoragePoolDao) SpmStartVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStartVDSCommandParameters) ThreadPoolUtil(org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) EnumSet(java.util.EnumSet) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) Instance(javax.enterprise.inject.Instance) GetStoragePoolInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetStoragePoolInfoVDSCommandParameters) RefObject(org.ovirt.engine.core.compat.RefObject) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageConstants(org.ovirt.engine.core.common.constants.StorageConstants) Set(java.util.Set) EventQueue(org.ovirt.engine.core.common.eventqueue.EventQueue) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) Collectors(java.util.stream.Collectors) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) VdsStaticDao(org.ovirt.engine.core.dao.VdsStaticDao) VdsDynamicDao(org.ovirt.engine.core.dao.VdsDynamicDao) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) IVdsEventListener(org.ovirt.engine.core.common.businessentities.IVdsEventListener) PostConstruct(javax.annotation.PostConstruct) AuditLogType(org.ovirt.engine.core.common.AuditLogType) SpmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters) DisconnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DisconnectStoragePoolVDSCommandParameters) SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) SpmStopVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) TransportFactory(org.ovirt.engine.core.vdsbroker.TransportFactory) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ThreadPools(org.ovirt.engine.core.utils.threadpool.ThreadPools) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) StoragePoolIsoMapDao(org.ovirt.engine.core.dao.StoragePoolIsoMapDao) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LinkedList(java.util.LinkedList) StorageDomainStaticDao(org.ovirt.engine.core.dao.StorageDomainStaticDao) Pair(org.ovirt.engine.core.common.utils.Pair) VdsSpmIdMapDao(org.ovirt.engine.core.dao.VdsSpmIdMapDao) Config(org.ovirt.engine.core.common.config.Config) VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) SpmStatus(org.ovirt.engine.core.common.businessentities.SpmStatus) LockManager(org.ovirt.engine.core.utils.lock.LockManager) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) EngineError(org.ovirt.engine.core.common.errors.EngineError) TransactionScopeOption(org.ovirt.engine.core.compat.TransactionScopeOption) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) StorageDomainDao(org.ovirt.engine.core.dao.StorageDomainDao) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncTaskStatusEnum(org.ovirt.engine.core.common.businessentities.AsyncTaskStatusEnum) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GetStoragePoolInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetStoragePoolInfoVDSCommandParameters) SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 3 with SpmStatusResult

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);
}
Also used : SpmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters) SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Guid(org.ovirt.engine.core.compat.Guid) HSMTaskGuidBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMTaskGuidBaseVDSCommandParameters)

Example 4 with SpmStatusResult

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

Example 5 with SpmStatusResult

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;
    }
}
Also used : SpmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters) SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) SpmStopVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

SpmStatusResult (org.ovirt.engine.core.common.businessentities.SpmStatusResult)7 SpmStatusVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters)5 Guid (org.ovirt.engine.core.compat.Guid)5 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 SpmStartVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SpmStartVDSCommandParameters)2 SpmStopVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters)2 VDSNetworkException (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException)2 MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1