use of com.sequenceiq.freeipa.kerberosmgmt.exception.DeleteException in project cloudbreak by hortonworks.
the class KeytabCleanupService method cleanupByEnvironment.
public void cleanupByEnvironment(String environmentCrn, String accountId) throws DeleteException {
LOGGER.debug("Request to cleanup vault for an environment for account {}: {}", accountId, environmentCrn);
try {
MDCBuilder.addEnvCrn(environmentCrn);
MDCBuilder.addAccountId(accountId);
vaultComponent.cleanupSecrets(environmentCrn, null, accountId);
keytabCacheService.deleteByEnvironmentCrn(environmentCrn);
} catch (Exception e) {
LOGGER.error("Cleanup cluster failed " + e.getLocalizedMessage(), e);
throw new DeleteException("Failed to cleanup " + e.getLocalizedMessage());
}
}
use of com.sequenceiq.freeipa.kerberosmgmt.exception.DeleteException in project cloudbreak by hortonworks.
the class CleanupService method removeVaultEntries.
@Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION))
public Pair<Set<String>, Map<String, String>> removeVaultEntries(Long stackId, Set<String> hosts) throws FreeIpaClientException {
Set<String> vaultCleanupSuccess = new HashSet<>();
Map<String, String> vaultCleanupFailed = new HashMap<>();
Stack stack = stackService.getStackById(stackId);
FreeIpaClient freeIpaClient = getFreeIpaClient(stackId);
for (String host : hosts) {
try {
HostRequest hostRequest = new HostRequest();
hostRequest.setEnvironmentCrn(stack.getEnvironmentCrn());
hostRequest.setServerHostName(host);
keytabCleanupService.removeHostRelatedKerberosConfiguration(hostRequest, stack.getAccountId(), freeIpaClient);
vaultCleanupSuccess.add(host);
} catch (DeleteException | FreeIpaClientException e) {
LOGGER.info("Vault secret cleanup failed for host: {}", host, e);
vaultCleanupFailed.put(host, e.getMessage());
}
}
return Pair.of(vaultCleanupSuccess, vaultCleanupFailed);
}
use of com.sequenceiq.freeipa.kerberosmgmt.exception.DeleteException in project cloudbreak by hortonworks.
the class KeytabCleanupService method cleanupByCluster.
public void cleanupByCluster(VaultCleanupRequest request, String accountId) throws DeleteException {
LOGGER.debug("Request to cleanup vault for a cluster for account {}: {}", accountId, request);
try {
MDCBuilder.addEnvCrn(request.getEnvironmentCrn());
MDCBuilder.addAccountId(accountId);
if (Strings.isNullOrEmpty(request.getClusterCrn())) {
LOGGER.error("Cluster CRN not provided. Vault is not cleaned-up");
throw new DeleteException("Cluster CRN is required");
} else {
MDCBuilder.addResourceCrn(request.getClusterCrn());
vaultComponent.cleanupSecrets(request.getEnvironmentCrn(), request.getClusterCrn(), accountId);
}
} catch (DeleteException e) {
throw e;
} catch (Exception e) {
LOGGER.error("Cleanup cluster failed " + e.getLocalizedMessage(), e);
throw new DeleteException("Failed to cleanup " + e.getLocalizedMessage());
}
}
Aggregations