Search in sources :

Example 6 with FreeIpaOperationFailedException

use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.

the class FreeIpaCreationRetrievalTask method checkStatus.

@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
    String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
    try {
        LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn);
        Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn);
        if (freeIpaOptional.isEmpty()) {
            throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn);
        }
        DescribeFreeIpaResponse freeIpa = freeIpaOptional.get();
        if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) {
            LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
            throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process.");
        }
        if (freeIpa.getStatus().isFailed()) {
            LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
            throw new FreeIpaOperationFailedException(String.format("Reason: '%s'", freeIpa.getStatusReason()));
        }
        if (freeIpa.getAvailabilityStatus() != null && freeIpa.getAvailabilityStatus().isAvailable()) {
            return true;
        }
    } catch (Exception e) {
        throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e);
    }
    return false;
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException)

Example 7 with FreeIpaOperationFailedException

use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.

the class FreeIpaDeletionHandler method detachChildEnvironmentFromFreeIpa.

private void detachChildEnvironmentFromFreeIpa(Environment environment) {
    try {
        DetachChildEnvironmentRequest detachChildEnvironmentRequest = new DetachChildEnvironmentRequest();
        detachChildEnvironmentRequest.setParentEnvironmentCrn(environment.getParentEnvironment().getResourceCrn());
        detachChildEnvironmentRequest.setChildEnvironmentCrn(environment.getResourceCrn());
        freeIpaService.detachChildEnvironment(detachChildEnvironmentRequest);
        if (lastChildEnvironmentInNetworkIsGettingDeleted(environment)) {
            try {
                dnsV1Endpoint.deleteDnsZoneBySubnet(environment.getParentEnvironment().getResourceCrn(), environment.getNetwork().getNetworkCidr());
            } catch (Exception e) {
                LOGGER.warn("Failed to delete dns zone of child environment.", e);
            }
        }
    } catch (FreeIpaOperationFailedException e) {
        if (e.getCause() instanceof NotFoundException) {
            LOGGER.warn("Child FreeIpa is already detached.", e);
        } else {
            throw e;
        }
    }
}
Also used : FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) NotFoundException(javax.ws.rs.NotFoundException) DetachChildEnvironmentRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.detachchildenv.DetachChildEnvironmentRequest) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) NotFoundException(javax.ws.rs.NotFoundException)

Example 8 with FreeIpaOperationFailedException

use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.

the class FreeIpaDeletionRetrievalTask method handleTimeout.

@Override
public void handleTimeout(FreeIpaPollerObject freeIpaPollerObject) {
    try {
        String envCrn = freeIpaPollerObject.getEnvironmentCrn();
        Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(envCrn);
        if (freeIpa.isEmpty()) {
            throw new FreeIpaOperationFailedException("FreeIpa was not found for environment: " + envCrn);
        }
        throw new FreeIpaOperationFailedException(String.format("Polling operation timed out, FreeIpa deletion failed. FreeIpa status: '%s' " + "statusReason: '%s'", freeIpa.get().getStatus(), freeIpa.get().getStatusReason()));
    } catch (Exception e) {
        throw new FreeIpaOperationFailedException("Polling operation timed out, FreeIpa deletion failed. Also failed to get FreeIpa status: " + e.getMessage(), e);
    }
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException)

Example 9 with FreeIpaOperationFailedException

use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.

the class FreeIpaService method startFreeIpa.

void startFreeIpa(String environmentCrn) {
    try {
        LOGGER.info("Starting freeipa");
        freeIpaV1Endpoint.start(environmentCrn);
    } catch (WebApplicationException e) {
        String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
        LOGGER.error(String.format("Failed to start FreeIpa cluster for environment '%s' due to: '%s'", environmentCrn, errorMessage), e);
        throw new FreeIpaOperationFailedException(errorMessage, e);
    }
}
Also used : FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 10 with FreeIpaOperationFailedException

use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.

the class FreeIpaService method stopFreeIpa.

void stopFreeIpa(String environmentCrn) {
    try {
        LOGGER.info("Stopping freeipa");
        freeIpaV1Endpoint.stop(environmentCrn);
    } catch (WebApplicationException e) {
        String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
        LOGGER.error(String.format("Failed to stop FreeIpa cluster for environment '%s' due to: '%s'", environmentCrn, errorMessage), e);
        throw new FreeIpaOperationFailedException(errorMessage, e);
    }
}
Also used : FreeIpaOperationFailedException(com.sequenceiq.environment.exception.FreeIpaOperationFailedException) WebApplicationException(javax.ws.rs.WebApplicationException)

Aggregations

FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)13 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)3 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)2 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)2 EnvStartFailedEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartFailedEvent)2 NotFoundException (javax.ws.rs.NotFoundException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 FreeIpaPollerObject (com.sequenceiq.environment.environment.flow.creation.handler.freeipa.FreeIpaPollerObject)1 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)1 EnvStopFailedEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopFailedEvent)1 UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)1 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)1 DetachChildEnvironmentRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.detachchildenv.DetachChildEnvironmentRequest)1 Test (org.junit.jupiter.api.Test)1