Search in sources :

Example 16 with VDSError

use of org.ovirt.engine.core.common.errors.VDSError in project ovirt-engine by oVirt.

the class StartRemoveGlusterVolumeBricksCommandTest method mockBackend.

private void mockBackend(boolean succeeded, EngineError errorCode) {
    doNothing().when(cmd).startSubStep();
    doReturn(asyncTaskToBeReturned).when(cmd).handleTaskReturn(asyncTaskToBeReturned);
    doNothing().when(cmd).updateBricksWithTaskID(asyncTaskToBeReturned);
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setReturnValue(asyncTaskToBeReturned);
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(eq(VDSCommandType.StartRemoveGlusterVolumeBricks), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 17 with VDSError

use of org.ovirt.engine.core.common.errors.VDSError in project ovirt-engine by oVirt.

the class VdsBrokerCommand method updateNetworkException.

private void updateNetworkException(VDSNetworkException ex, String message) {
    VDSError error = ex.getVdsError();
    if (error == null) {
        error = new VDSError(EngineError.VDS_NETWORK_ERROR, message);
        ex.setVdsError(error);
    }
    error.setVdsId(getVds().getId());
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError)

Example 18 with VDSError

use of org.ovirt.engine.core.common.errors.VDSError in project ovirt-engine by oVirt.

the class SpmStopVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case StoragePoolUnknown:
        case SpmStatusError:
            // ignore this, the parser can handle the empty result.
            break;
        case TaskInProgress:
            getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().message));
            getVDSReturnValue().setSucceeded(false);
            break;
        default:
            super.proceedProxyReturnValue();
            initializeVdsError(returnStatus);
            break;
    }
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) EngineError(org.ovirt.engine.core.common.errors.EngineError)

Example 19 with VDSError

use of org.ovirt.engine.core.common.errors.VDSError in project ovirt-engine by oVirt.

the class SpmStopVDSCommand method executeVdsBrokerCommand.

@Override
protected void executeVdsBrokerCommand() {
    boolean lockAcquired = false;
    try {
        if (canVdsBeReached()) {
            lockAcquired = lockManager.acquireLock(retrieveVdsExecutionLock()).getFirst();
            if (!lockAcquired) {
                getVDSReturnValue().setVdsError(new VDSError(EngineError.ENGINE, "Failed to acquire vds execution lock - related operation is under execution"));
                getVDSReturnValue().setSucceeded(false);
                return;
            }
            boolean performSpmStop = true;
            Map<Guid, AsyncTaskStatus> unclearedTasks = null;
            try {
                VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(getVds().getId()));
                if (isNotSPM(vdsReturnValue)) {
                    return;
                }
                getVDSReturnValue().setSucceeded(vdsReturnValue.getSucceeded());
                getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
                if (vdsReturnValue.getReturnValue() != null) {
                    unclearedTasks = (HashMap<Guid, AsyncTaskStatus>) vdsReturnValue.getReturnValue();
                    performSpmStop = unclearedTasks.isEmpty();
                }
            } catch (Exception e) {
                performSpmStop = false;
                log.info("SpmStopVDSCommand::Could not get tasks on vds '{}': {}", getVds().getName(), e.getMessage());
                log.debug("Exception", e);
            }
            if (performSpmStop) {
                log.info("SpmStopVDSCommand::Stopping SPM on vds '{}', pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
                status = getBroker().spmStop(getParameters().getStoragePoolId().toString());
                proceedProxyReturnValue();
            } else {
                getVDSReturnValue().setSucceeded(false);
                if (getVDSReturnValue().getVdsError() == null) {
                    String unclearedTasksDetails = unclearedTasks.entrySet().stream().map(entry -> String.format("Task '%s', status '%s'", entry.getKey(), entry.getValue().getStatus())).collect(Collectors.joining("\n"));
                    log.error("SpmStopVDSCommand::Not stopping SPM on vds '{}', pool id '{}' as there are uncleared tasks '{}'", getVds().getName(), getParameters().getStoragePoolId(), unclearedTasksDetails);
                    VDSError error = new VDSError(EngineError.TaskInProgress, unclearedTasksDetails);
                    getVDSReturnValue().setVdsError(error);
                } else if (getVDSReturnValue().getVdsError().getCode() == EngineError.VDS_NETWORK_ERROR) {
                    log.info("SpmStopVDSCommand::Could not get tasks on vds '{}' - network exception, not stopping spm! pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
                }
            }
        } else {
            log.info("SpmStopVDSCommand:: vds '{}' is in '{}' status - not performing spm stop, pool id '{}'", getVds().getName(), getVds().getStatus(), getParameters().getStoragePoolId());
            getVDSReturnValue().setVdsError(new VDSError(EngineError.VDS_NETWORK_ERROR, "Vds is in incorrect status"));
            getVDSReturnValue().setSucceeded(false);
        }
    } catch (RuntimeException exp) {
        log.warn("Could not stop spm of pool '{}' on vds '{}': {}", getParameters().getStoragePoolId(), getParameters().getVdsId(), exp.getMessage());
        log.debug("Exception", exp);
        getVDSReturnValue().setExceptionObject(exp);
        getVDSReturnValue().setSucceeded(false);
    } finally {
        if (lockAcquired) {
            lockManager.releaseLock(retrieveVdsExecutionLock());
        }
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Guid(org.ovirt.engine.core.compat.Guid) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) LockManager(org.ovirt.engine.core.utils.lock.LockManager) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) EngineError(org.ovirt.engine.core.common.errors.EngineError) Inject(javax.inject.Inject) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Map(java.util.Map) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) Collections(java.util.Collections) VDSError(org.ovirt.engine.core.common.errors.VDSError) Pair(org.ovirt.engine.core.common.utils.Pair) SpmStopVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters) VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDSError(org.ovirt.engine.core.common.errors.VDSError) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 20 with VDSError

use of org.ovirt.engine.core.common.errors.VDSError in project ovirt-engine by oVirt.

the class IrsBrokerCommand method executeVDSCommand.

@Override
protected void executeVDSCommand() {
    AtomicBoolean isStartReconstruct = new AtomicBoolean(false);
    getCurrentIrsProxy().runInControlledConcurrency(() -> {
        try {
            if (getIrsProxy() != null) {
                executeIrsBrokerCommand();
            } else {
                if (getVDSReturnValue().getVdsError() == null) {
                    getVDSReturnValue().setExceptionString("Cannot allocate IRS server");
                    VDSError tempVar = new VDSError();
                    tempVar.setCode(EngineError.IRS_REPOSITORY_NOT_FOUND);
                    tempVar.setMessage("Cannot allocate IRS server");
                    getVDSReturnValue().setVdsError(tempVar);
                }
                getVDSReturnValue().setSucceeded(false);
            }
        } catch (UndeclaredThrowableException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(new VDSError(EngineError.VDS_NETWORK_ERROR, ex.getMessage()));
            if (ExceptionUtils.getRootCause(ex) != null) {
                logException(ExceptionUtils.getRootCause(ex));
            } else {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            failover();
        } catch (TransportRunTimeException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            if (ex.isNetworkError()) {
                log.error("IrsBroker::Failed::{} - network exception.", getCommandName());
                getVDSReturnValue().setSucceeded(false);
            } else {
                log.error("IrsBroker::Failed::{}", getCommandName());
                log.debug(LoggedUtils.getObjectId(this), this, ex);
                throw new IRSProtocolException(ex);
            }
        } catch (IRSNoMasterDomainException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            log.error("IrsBroker::Failed::{}: {}", getCommandName(), ex.getMessage());
            log.debug("Exception", ex);
            if ((ex.getVdsError() == null || ex.getVdsError().getCode() != EngineError.StoragePoolWrongMaster) && getCurrentIrsProxy().getHasVdssForSpmSelection()) {
                failover();
            } else {
                isStartReconstruct.set(true);
            }
        } catch (IRSUnicodeArgumentException ex) {
            throw new IRSGenericException("UNICODE characters are not supported.", ex);
        } catch (IRSStoragePoolStatusException | IrsOperationFailedNoFailoverException ex) {
            throw ex;
        } catch (IRSNonOperationalException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            logException(ex);
            if (ex.getVdsError() != null && EngineError.SpmStatusError == ex.getVdsError().getCode()) {
                getCurrentIrsProxy().setCurrentVdsId(Guid.Empty);
            }
            failover();
        } catch (IRSErrorException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            logException(ex);
            if (log.isDebugEnabled()) {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            failover();
        } catch (RuntimeException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            if (ex instanceof VDSExceptionBase) {
                getVDSReturnValue().setVdsError(((VDSExceptionBase) ex).getVdsError());
            }
            if (ExceptionUtils.getRootCause(ex) != null && ExceptionUtils.getRootCause(ex) instanceof SocketException) {
                logException(ExceptionUtils.getRootCause(ex));
            } else {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            // always failover because of changes in vdsm error, until we
            // realize what to do in each case:
            failover();
        } finally {
            getCurrentIrsProxy().getTriedVdssList().clear();
        }
    });
    if (isStartReconstruct.get()) {
        startReconstruct();
    }
}
Also used : SocketException(java.net.SocketException) TransportRunTimeException(org.ovirt.engine.core.vdsbroker.TransportRunTimeException) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VDSError(org.ovirt.engine.core.common.errors.VDSError) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Aggregations

VDSError (org.ovirt.engine.core.common.errors.VDSError)24 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)13 EngineError (org.ovirt.engine.core.common.errors.EngineError)7 Guid (org.ovirt.engine.core.compat.Guid)3 Map (java.util.Map)2 GlusterVolumeTaskStatusEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 SocketException (java.net.SocketException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)1 HostJobInfo (org.ovirt.engine.core.common.businessentities.HostJobInfo)1 HostJobStatus (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobStatus)1 HostJobType (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobType)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1