use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class CheckImageAction method doExecute.
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
CheckImageResult checkImageResult = stackCreationService.checkImage(context);
switch(checkImageResult.getImageStatus()) {
case IN_PROGRESS:
repeat(context);
break;
case CREATE_FINISHED:
sendEvent(context);
break;
case CREATE_FAILED:
LOGGER.info("Error during image status check: {}", payload);
int faultNum = getFaultNum(variables) + 1;
if (faultNum == FAULT_TOLERANCE) {
removeFaultNum(variables);
throw new CloudbreakServiceException("Image copy failed.");
} else {
setFaultNum(variables, faultNum);
repeat(context);
}
break;
default:
LOGGER.error("Unknown image status: {}", checkImageResult.getImageStatus());
break;
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class GrpcUmsClientTest method testHasRightsUsesCheckRightWhenRequestNumberIsLessThenThreshold.
@Test
public void testHasRightsUsesCheckRightWhenRequestNumberIsLessThenThreshold() {
String resourceCrn1 = CrnTestUtil.getDatahubCrnBuilder().setAccountId("a1").setResource("r1").build().toString();
String resourceCrn2 = CrnTestUtil.getDatahubCrnBuilder().setAccountId("a1").setResource("r2").build().toString();
doNothing().when(authorizationClient).checkRight(REQUEST_ID.get(), USER_CRN, "right", resourceCrn1);
doThrow(new RuntimeException("Permission denied")).when(authorizationClient).checkRight(REQUEST_ID.get(), USER_CRN, "right", resourceCrn2);
CloudbreakServiceException exception = assertThrows(CloudbreakServiceException.class, () -> {
underTest.hasRights(USER_CRN, List.of(resourceCrn1, resourceCrn2), "right", REQUEST_ID, regionAwareInternalCrnGeneratorFactory);
});
assertEquals("Authorization failed due to user management service call failed with error.", exception.getMessage());
InOrder inOrder = inOrder(authorizationClient);
inOrder.verify(authorizationClient).checkRight(REQUEST_ID.get(), USER_CRN, "right", resourceCrn1);
inOrder.verify(authorizationClient).checkRight(REQUEST_ID.get(), USER_CRN, "right", resourceCrn2);
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class SecretAspects method proceedDelete.
private Object proceedDelete(ProceedingJoinPoint proceedingJoinPoint) {
Collection<Object> entities = convertFirstArgToCollection(proceedingJoinPoint);
for (Object entity : entities) {
try {
for (Field field : entity.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(SecretValue.class)) {
LOGGER.debug("Found SecretValue annotation on {}", field);
field.setAccessible(true);
Secret path = (Secret) field.get(entity);
if (path != null && path.getSecret() != null) {
secretService.delete(path.getSecret());
LOGGER.debug("Secret deleted at path: {}", path);
} else {
LOGGER.debug("Secret is null for field: {}.{}", field.getDeclaringClass(), field.getName());
}
}
}
} catch (IllegalArgumentException e) {
LOGGER.error("Given entity isn't instance of TenantAwareResource or AccountIdAwareResource. Secret is not deleted!", e);
throw new CloudbreakServiceException(e);
} catch (Exception e) {
LOGGER.warn("Looks like something went wrong with Secret store. Secret is not deleted!", e);
throw new CloudbreakServiceException(e);
}
}
Object proceed;
try {
proceed = proceedingJoinPoint.proceed();
} catch (RuntimeException re) {
LOGGER.warn("Failed to invoke repository delete", re);
throw re;
} catch (Throwable throwable) {
LOGGER.error("Failed to invoke repository delete", throwable);
throw new CloudbreakServiceException(throwable);
}
return proceed;
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClouderaManagerSetupServiceTest method testRefreshParcelReposWhenApiExceptionOccursShouldThrowCloudbreakServiceException.
@Test
public void testRefreshParcelReposWhenApiExceptionOccursShouldThrowCloudbreakServiceException() {
ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
when(clouderaManagerRepo.getPredefined()).thenReturn(true);
when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
doThrow(new ClouderaManagerOperationFailedException("error")).when(clouderaManagerApiFactory).getClouderaManagerResourceApi(any(ApiClient.class));
CloudbreakServiceException actual = assertThrows(CloudbreakServiceException.class, () -> underTest.refreshParcelRepos());
assertEquals(CloudbreakServiceException.class, actual.getClass());
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClusterTemplateViewToClusterTemplateViewV4ResponseConverter method convert.
public ClusterTemplateViewV4Response convert(ClusterTemplateView source) {
ClusterTemplateViewV4Response clusterTemplateViewV4Response = new ClusterTemplateViewV4Response();
clusterTemplateViewV4Response.setName(source.getName());
clusterTemplateViewV4Response.setDescription(source.getDescription());
clusterTemplateViewV4Response.setCrn(source.getResourceCrn());
clusterTemplateViewV4Response.setCloudPlatform(source.getCloudPlatform());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setId(source.getId());
clusterTemplateViewV4Response.setDatalakeRequired(source.getDatalakeRequired());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setType(source.getType());
clusterTemplateViewV4Response.setFeatureState(source.getFeatureState());
if (source.getStackTemplate() != null) {
ClusterTemplateStackApiView stackTemplate = source.getStackTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(stackTemplate));
if (stackTemplate.getCluster() != null) {
ClusterTemplateClusterApiView cluster = stackTemplate.getCluster();
clusterTemplateViewV4Response.setStackType(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackType() : "");
clusterTemplateViewV4Response.setStackVersion(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackVersion() : "");
}
if (stackTemplate.getEnvironmentCrn() != null) {
clusterTemplateViewV4Response.setEnvironmentCrn(stackTemplate.getEnvironmentCrn());
}
} else if (source.getStatus().isDefault()) {
try {
DistroXV1Request distroXV1Request = new Json(getTemplateString(source.getTemplateContent())).get(DefaultClusterTemplateV4Request.class).getDistroXTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(distroXV1Request));
clusterTemplateViewV4Response.setStackType("CDH");
clusterTemplateViewV4Response.setStackVersion(source.getClouderaRuntimeVersion());
} catch (IOException e) {
LOGGER.error("CDP was not able to convert back {} template: {}", source.getName(), e.getMessage());
throw new CloudbreakServiceException("CDP was not able to give back your template: ", e);
}
}
clusterTemplateViewV4Response.setCreated(source.getCreated());
return clusterTemplateViewV4Response;
}
Aggregations