use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterCreationService method handleClusterCreationFailure.
public void handleClusterCreationFailure(StackView stackView, Exception exception, ProvisionType provisionType) {
if (stackView.getClusterView() != null) {
String errorMessage = getErrorMessageFromException(exception);
DetailedStackStatus failureDetailedStatus = provisionType.isRecovery() ? DetailedStackStatus.CLUSTER_RECOVERY_FAILED : DetailedStackStatus.CLUSTER_CREATE_FAILED;
stackUpdater.updateStackStatus(stackView.getId(), failureDetailedStatus, errorMessage);
flowMessageService.fireEventAndLog(stackView.getId(), CREATE_FAILED.name(), CLUSTER_CREATE_FAILED, errorMessage);
} else {
LOGGER.info("Cluster was null. Flow action was not required.");
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackCreationService method handleStackCreationFailure.
public void handleStackCreationFailure(StackView stack, Exception errorDetails, ProvisionType provisionType) {
LOGGER.info("Error during stack creation flow:", errorDetails);
String errorReason = errorDetails == null ? "Unknown error" : errorDetails.getMessage();
if (errorDetails instanceof CancellationException || ExceptionUtils.getRootCause(errorDetails) instanceof CancellationException) {
LOGGER.debug("The flow has been cancelled.");
} else {
if (!stack.isStackInDeletionPhase()) {
handleFailure(stack, errorReason);
DetailedStackStatus failureStatus = (provisionType == ProvisionType.REGULAR) ? PROVISION_FAILED : CLUSTER_RECOVERY_FAILED;
stackUpdater.updateStackStatus(stack.getId(), failureStatus, errorReason);
flowMessageService.fireEventAndLog(stack.getId(), Status.CREATE_FAILED.name(), STACK_INFRASTRUCTURE_CREATE_FAILED, errorReason);
} else {
flowMessageService.fireEventAndLog(stack.getId(), UPDATE_IN_PROGRESS.name(), STACK_INFRASTRUCTURE_CREATE_FAILED, errorReason);
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackTerminationService method handleStackTerminationError.
public void handleStackTerminationError(StackView stackView, Exception errorDetails, boolean forced) {
Long stackId = stackView.getId();
String stackUpdateMessage;
ResourceEvent resourceEvent;
DetailedStackStatus status;
if (!forced) {
stackUpdateMessage = "Termination failed: " + errorDetails.getMessage();
status = DetailedStackStatus.DELETE_FAILED;
resourceEvent = STACK_INFRASTRUCTURE_DELETE_FAILED;
stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
LOGGER.debug("Error during stack termination flow: ", errorDetails);
} else {
clusterService.updateClusterStatusByStackId(stackId, DetailedStackStatus.CLUSTER_DELETE_COMPLETED);
terminationService.finalizeTermination(stackId, true);
stackUpdateMessage = "Stack was force terminated.";
status = DetailedStackStatus.DELETE_COMPLETED;
resourceEvent = STACK_FORCED_DELETE_COMPLETED;
}
flowMessageService.fireEventAndLog(stackId, status.name(), resourceEvent, stackUpdateMessage);
metricService.incrementMetricCounter(MetricType.STACK_TERMINATION_FAILED, stackView, errorDetails);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Long stackId, Status newStatus, DetailedStackStatus newDetailedStatus, String statusReason) {
Stack stack = stackService.getByIdWithTransaction(stackId);
StackStatus actualStackStatus = stack.getStackStatus();
LOGGER.info("Update stack status from: {}/{} to: {}/{} stack: {} reason: {}", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus(), newStatus, newDetailedStatus, stackId, statusReason);
if (actualStackStatus.getStatus().equals(newStatus)) {
LOGGER.debug("New status is the same as previous status {}/{}, skip status update.", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus());
return stack;
} else if (!stack.isDeleteCompleted()) {
stack.setStackStatus(new StackStatus(stack, newStatus, statusReason, newDetailedStatus));
Cluster cluster = stack.getCluster();
if (newStatus.isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
if (cluster != null) {
InMemoryStateStore.deleteCluster(cluster.getId());
}
} else {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(newStatus));
if (cluster != null) {
InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(newStatus));
}
}
stack = stackService.save(stack);
saveDeprecatedClusterStatus(statusReason, stack, newStatus);
usageLoggingUtil.logClusterStatusChangeUsageEvent(actualStackStatus.getStatus(), newStatus, cluster);
} else {
LOGGER.info("Stack is in DELETE_COMPLETED status, cannot update status.");
}
return stack;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method skipStackStatusUpdateWhenActualStatusEqualsNewStatus.
@Test
public void skipStackStatusUpdateWhenActualStatusEqualsNewStatus() {
Stack stack = TestUtil.stack();
DetailedStackStatus newStatus = DetailedStackStatus.AVAILABLE;
when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
Stack modifiedStack = underTest.updateStackStatus(1L, newStatus, "newReason");
assertEquals(stack.getStatus(), modifiedStack.getStatus());
assertEquals(newStatus.getStatus(), modifiedStack.getStatus());
verify(stackService, never()).save(any());
}
Aggregations