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);
}
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());
}
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;
}
}
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());
}
}
}
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();
}
}
Aggregations