use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class RebootActions method rebootFailureAction.
@Bean(name = "REBOOT_FAILED_STATE")
public Action<?, ?> rebootFailureAction() {
return new AbstractRebootAction<>(InstanceFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(RebootContext context, InstanceFailureEvent payload, Map<Object, Object> variables) {
addMdcOperationId(variables);
rebootService.handleInstanceRebootError(context);
String message = String.format("Rebooting failed for %s.", context.getInstanceIds());
LOGGER.error(message);
Stack stack = context.getStack();
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
FailureDetails failureDetails = new FailureDetails(stack.getEnvironmentCrn(), message);
operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
sendEvent(context, new InstanceEvent(RebootEvent.REBOOT_FAIL_HANDLED_EVENT.event(), context.getStack().getId(), context.getInstanceIdList()));
}
@Override
protected RebootContext createFlowContext(FlowParameters flowParameters, StateContext<RebootState, RebootEvent> stateContext, InstanceFailureEvent payload) {
Long stackId = payload.getResourceId();
Stack stack = stackService.getStackById(stackId);
MDCBuilder.buildMdcContext(stack);
return new RebootContext(flowParameters, stack, payload.getInstanceIds().stream().map(instanceId -> {
InstanceMetaData md = new InstanceMetaData();
md.setInstanceId(instanceId);
return md;
}).collect(Collectors.toList()), null, null);
}
@Override
protected Object getFailurePayload(InstanceFailureEvent payload, Optional<RebootContext> flowContext, Exception ex) {
return new InstanceFailureEvent(payload.getResourceId(), ex, payload.getInstanceIds());
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<InstanceFailureEvent>> payloadConverters) {
payloadConverters.add(new RebootInstancesResultToCleanupFailureEventConverter());
payloadConverters.add(new WaitUntilAvailableFailedToInstanceFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class ProviderChecker method updateStatuses.
private InstanceStatus updateStatuses(CloudVmInstanceStatus vmInstanceStatus, InstanceMetaData instanceMetaData, Map<InstanceMetaData, DetailedStackStatus> instanceHealthStatusMap) {
LOGGER.info(":::Auto sync::: {} instance metadata status update in progress, new status: {}", instanceMetaData.getShortHostname(), vmInstanceStatus);
InstanceStatus status = null;
switch(vmInstanceStatus.getStatus()) {
case STARTED:
if (DetailedStackStatus.UNREACHABLE == instanceHealthStatusMap.get(instanceMetaData)) {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNREACHABLE);
status = InstanceStatus.UNREACHABLE;
} else if (DetailedStackStatus.UNHEALTHY == instanceHealthStatusMap.get(instanceMetaData)) {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNHEALTHY);
status = InstanceStatus.UNHEALTHY;
} else {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.CREATED);
status = InstanceStatus.CREATED;
}
break;
case STOPPED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.STOPPED);
status = InstanceStatus.STOPPED;
break;
case FAILED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.FAILED);
status = InstanceStatus.FAILED;
break;
case TERMINATED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_ON_PROVIDER_SIDE);
status = InstanceStatus.DELETED_ON_PROVIDER_SIDE;
break;
case TERMINATED_BY_PROVIDER:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_BY_PROVIDER);
status = InstanceStatus.DELETED_BY_PROVIDER;
break;
default:
LOGGER.info(":::Auto sync::: the '{}' status is not converted", vmInstanceStatus.getStatus());
}
if (updateStatus) {
instanceMetaDataService.save(instanceMetaData);
} else {
LOGGER.debug("updateStatus flag is false, don't update status");
}
return status;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.
the class KeytabConfigurationHandler method accept.
@Override
public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) {
Long stackId = keytabConfigurationRequestEvent.getData().getResourceId();
Selectable response;
try {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName());
boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn());
if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) {
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig);
KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse);
hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId()));
}
response = new KeytabConfigurationSuccess(stackId);
} catch (Exception e) {
LOGGER.info("Error during keytab configuration, stackId: " + stackId, e);
KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e);
response = new KeytabConfigurationFailed(stackId, configurationException);
}
eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED 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;
}
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED 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);
}
}
Aggregations