use of com.sequenceiq.cloudbreak.service.Retry.ActionFailedException in project cloudbreak by hortonworks.
the class AwsTerminateService method isStackDeleted.
private Boolean isStackDeleted(AmazonCloudFormationClient cfRetryClient, DescribeStacksRequest describeStacksRequest, DeleteStackRequest deleteStackRequest) {
cfRetryClient.deleteStack(deleteStackRequest);
Waiter<DescribeStacksRequest> stackDeleteCompleteWaiter = cfRetryClient.waiters().stackDeleteComplete();
try {
LOGGER.debug("Waiting for final state of CloudFormation deletion attempt.");
WaiterParameters<DescribeStacksRequest> describeStacksRequestWaiterParameters = new WaiterParameters<>(describeStacksRequest).withPollingStrategy(getBackoffCancellablePollingStrategy(null));
stackDeleteCompleteWaiter.run(describeStacksRequestWaiterParameters);
} catch (Exception e) {
LOGGER.debug("CloudFormation stack delete ended in failed state. Delete operation will be retried.");
throw new ActionFailedException(e.getMessage());
}
return Boolean.TRUE;
}
use of com.sequenceiq.cloudbreak.service.Retry.ActionFailedException in project cloudbreak by hortonworks.
the class HeartbeatService method heartbeat.
private void heartbeat(boolean unLeaderIt) {
if (periscopeNodeConfig.isNodeIdSpecified()) {
String nodeId = periscopeNodeConfig.getId();
try {
retryService.testWith2SecDelayMax5Times(() -> {
try {
PeriscopeNode self = periscopeNodeRepository.findById(nodeId).orElse(new PeriscopeNode(nodeId));
self.setLastUpdated(clock.getCurrentTimeMillis());
if (unLeaderIt) {
self.setLeader(false);
}
periscopeNodeRepository.save(self);
} catch (RuntimeException e) {
LOGGER.error("Failed to update the heartbeat timestamp", e);
throw new ActionFailedException(e.getMessage());
}
return Boolean.TRUE;
});
} catch (ActionFailedException af) {
LOGGER.error("Failed to update the heartbeat timestamp 5 times for node {}: {}", nodeId, af.getMessage());
try {
transactionService.required(() -> {
clusterRepository.deallocateClustersOfNode(nodeId);
return null;
});
} catch (TransactionExecutionException e) {
LOGGER.error("Unable to deallocate clusters", e);
}
}
}
}
use of com.sequenceiq.cloudbreak.service.Retry.ActionFailedException in project cloudbreak by hortonworks.
the class AzureResourceConnector method terminate.
@Override
public List<CloudResourceStatus> terminate(AuthenticatedContext ac, CloudStack stack, List<CloudResource> resources) {
AzureClient client = ac.getParameter(AzureClient.class);
String resourceGroupName = azureResourceGroupMetadataProvider.getResourceGroupName(ac.getCloudContext(), stack);
ResourceGroupUsage resourceGroupUsage = azureResourceGroupMetadataProvider.getResourceGroupUsage(stack);
if (resourceGroupUsage != ResourceGroupUsage.MULTIPLE) {
String deploymentName = azureUtils.getStackName(ac.getCloudContext());
List<CloudResource> transientResources = azureTerminationHelperService.handleTransientDeployment(client, resourceGroupName, deploymentName);
NullUtil.doIfNotNull(transientResources, resources::addAll);
azureTerminationHelperService.terminate(ac, stack, resources);
return check(ac, Collections.emptyList());
} else {
try {
try {
azureUtils.checkResourceGroupExistence(client, resourceGroupName);
client.deleteResourceGroup(resourceGroupName);
} catch (ActionFailedException ignored) {
LOGGER.debug("Resource group not found with name: {}", resourceGroupName);
}
} catch (CloudException e) {
if (e.response().code() != AzureConstants.NOT_FOUND) {
throw new CloudConnectorException(String.format("Could not delete resource group: %s", resourceGroupName), e);
} else {
return check(ac, Collections.emptyList());
}
}
return check(ac, resources);
}
}
Aggregations