use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaServiceTest method internalDescribeApiNotFoundTest.
@Test
void internalDescribeApiNotFoundTest() {
when(freeIpaV1Endpoint.describeInternal(eq(ENVCRN), eq("1111"))).thenThrow(new javax.ws.rs.NotFoundException());
FreeIpaOperationFailedException freeIpaOperationFailedException = Assertions.assertThrows(FreeIpaOperationFailedException.class, () -> underTest.internalDescribe(ENVCRN, "1111"));
String errorMessage = freeIpaOperationFailedException.getMessage();
assertThat(errorMessage).isEqualTo("Freeipa internal describe response is NOT FOUND, but response reason is not the expected type");
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaDeletionHandler method deleteFreeIpa.
private void deleteFreeIpa(Environment environment, boolean forced) {
freeIpaService.delete(environment.getResourceCrn(), forced);
ExtendedPollingResult result = freeIpaPollingService.pollWithTimeout(new FreeIpaDeletionRetrievalTask(freeIpaService), new FreeIpaPollerObject(environment.getId(), environment.getResourceCrn()), FreeIpaDeletionRetrievalTask.FREEIPA_RETRYING_INTERVAL, FreeIpaDeletionRetrievalTask.FREEIPA_RETRYING_COUNT, FreeIpaDeletionRetrievalTask.FREEIPA_FAILURE_COUNT);
if (!result.isSuccess()) {
String message = "Failed to delete FreeIpa! (" + result.getPollingResult().name() + ") " + getIfNotNull(result.getException(), Throwable::getMessage);
LOGGER.info(message);
throw new FreeIpaOperationFailedException(message);
}
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaDeletionRetrievalTask method checkStatus.
@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
try {
LOGGER.info("Checking the state of FreeIpa termination progress for environment: '{}'", environmentCrn);
Optional<DescribeFreeIpaResponse> freeIpaResponse = freeIpaService.describe(environmentCrn);
if (freeIpaResponse.isPresent()) {
if (freeIpaResponse.get().getStatus() == Status.DELETE_FAILED) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed: " + freeIpaResponse.get().getStatusReason());
}
if (!freeIpaResponse.get().getStatus().isSuccessfullyDeleted()) {
return false;
}
} else {
LOGGER.info("FreeIpa was not found.");
return true;
}
} catch (Exception e) {
throw new FreeIpaOperationFailedException("FreeIpa deletion operation failed. " + e.getMessage(), e);
}
return true;
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnFreeIpaHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
freeIpaService.describe(environmentDto.getResourceCrn()).ifPresentOrElse(freeIpa -> {
if (freeIpa.getStatus() == null || freeIpa.getAvailabilityStatus() == null) {
throw new FreeIpaOperationFailedException("FreeIPA status is unpredictable, upgrading of Cluster Connectivity Manager will be interrupted.");
} else if (!freeIpa.getStatus().isCcmUpgradeablePhase()) {
throw new FreeIpaOperationFailedException("FreeIPA is not in a valid state to upgrade Cluster Connectivity Manager. Current state is: " + freeIpa.getStatus().name());
} else {
LOGGER.info("CCM on FreeIPA will be upgraded.");
freeIpaPollerService.waitForCcmUpgrade(environmentDto.getId(), environmentDto.getResourceCrn());
}
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_TUNNEL_UPDATE_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_TUNNEL_UPDATE_EVENT event sent");
}, () -> {
throw new FreeIpaOperationFailedException(String.format("FreeIPA cannot be found for environment %s", environmentDto.getName()));
});
} catch (Exception e) {
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(environmentDto, e, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_ON_FREEIPA_FAILED event sent");
}
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class SynchronizeUsersHandler method accept.
@Override
public void accept(Event<EnvironmentStartDto> environmentStartDtoEvent) {
LOGGER.debug("User synchronization is {}.", synchronizeOnStartEnabled ? "enabled" : "disabled");
EnvironmentDto environmentDto = environmentStartDtoEvent.getData().getEnvironmentDto();
try {
if (synchronizeOnStartEnabled) {
freeIpaService.describe(environmentDto.getResourceCrn()).ifPresent(freeIpa -> {
if (freeIpa.getStatus() != null && freeIpa.getAvailabilityStatus() != null && !freeIpa.getAvailabilityStatus().isAvailable()) {
throw new FreeIpaOperationFailedException("FreeIPA is not in AVAILABLE state to synchronize users! Current state is: " + freeIpa.getStatus().name());
}
});
freeIpaPollerService.waitForSynchronizeUsers(environmentDto.getId(), environmentDto.getResourceCrn());
}
EnvStartEvent envStartEvent = EnvStartEvent.EnvStartEventBuilder.anEnvStartEvent().withSelector(EnvStartStateSelectors.FINISH_ENV_START_EVENT.selector()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).withDataHubStart(environmentStartDtoEvent.getData().getDataHubStart()).build();
eventSender().sendEvent(envStartEvent, environmentStartDtoEvent.getHeaders());
} catch (Exception e) {
EnvStartFailedEvent failedEvent = new EnvStartFailedEvent(environmentDto, e, EnvironmentStatus.START_SYNCHRONIZE_USERS_FAILED);
eventSender().sendEvent(failedEvent, environmentStartDtoEvent.getHeaders());
}
}
Aggregations