use of com.sequenceiq.cloudbreak.domain.stack.StackPatchType in project cloudbreak by hortonworks.
the class ExistingStackPatcherJob method applyStackPatch.
private boolean applyStackPatch(ExistingStackPatchService existingStackPatchService, Stack stack) throws JobExecutionException {
StackPatchType stackPatchType = existingStackPatchService.getStackPatchType();
if (!existingStackPatchService.isStackAlreadyFixed(stack)) {
try {
if (existingStackPatchService.isAffected(stack)) {
LOGGER.debug("Stack {} needs patch for {}", stack.getResourceCrn(), stackPatchType);
stackPatchUsageReporterService.reportAffected(stack, stackPatchType);
boolean success = existingStackPatchService.apply(stack);
if (success) {
stackPatchUsageReporterService.reportSuccess(stack, stackPatchType);
}
return success;
} else {
LOGGER.debug("Stack {} is not affected by {}", stack.getResourceCrn(), stackPatchType);
return true;
}
} catch (ExistingStackPatchApplyException e) {
String message = String.format("Failed to patch stack %s for %s", stack.getResourceCrn(), stackPatchType);
LOGGER.error(message, e);
stackPatchUsageReporterService.reportFailure(stack, stackPatchType, e.getMessage());
throw new JobExecutionException(message, e);
}
} else {
LOGGER.debug("Stack {} was already patched for {}", stack.getResourceCrn(), stackPatchType);
return true;
}
}
Aggregations