use of com.openshift.cloud.api.connector.models.ConnectorStatusStatus in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorWorker method deleteDependencies.
@Override
public ConnectorEntity deleteDependencies(Work work, ConnectorEntity connectorEntity) {
LOGGER.info("Destroying dependencies for '{}' [{}]", connectorEntity.getName(), connectorEntity.getId());
// This is idempotent as it gets overridden later depending on actual state
connectorEntity.setStatus(ManagedResourceStatus.DELETING);
connectorEntity.setDependencyStatus(ManagedResourceStatus.DELETING);
connectorEntity = persist(connectorEntity);
Connector connector = connectorsApi.getConnector(connectorEntity);
// Step 3 - Connector has been deleted and does not exist: Clean up Kafka Topic
if (Objects.isNull(connector)) {
return deleteTopic(connectorEntity);
}
ConnectorStatusStatus status = connector.getStatus();
if (Objects.isNull(status)) {
return connectorEntity;
}
if (status.getState() == ConnectorState.DELETED) {
LOGGER.debug("Managed Connector for '{}' [{}] has status 'DELETED'. Continuing with deletion of Kafka Topic..", connectorEntity.getName(), connectorEntity.getId());
return deleteTopic(connectorEntity);
}
if (status.getState() == ConnectorState.FAILED) {
LOGGER.debug("Managed Connector for '{}' [{}] has status 'FAILED'. Continuing with deletion of Kafka Topic..", connectorEntity.getName(), connectorEntity.getId());
return deleteTopic(connectorEntity);
}
// Step 2 - Delete Connector
LOGGER.debug("Deleting Managed Connector for '{}' [{}]", connectorEntity.getName(), connectorEntity.getId());
connectorsApi.deleteConnector(connectorEntity.getConnectorExternalId());
return connectorEntity;
}
Aggregations