Search in sources :

Example 16 with ConnectorStatusStatus

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;
}
Also used : Connector(com.openshift.cloud.api.connector.models.Connector) ConnectorStatusStatus(com.openshift.cloud.api.connector.models.ConnectorStatusStatus)

Aggregations

Connector (com.openshift.cloud.api.connector.models.Connector)16 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)16 QuarkusTest (io.quarkus.test.junit.QuarkusTest)8 Test (org.junit.jupiter.api.Test)8 ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)6 Bridge (com.redhat.service.smartevents.manager.models.Bridge)6 Processor (com.redhat.service.smartevents.manager.models.Processor)6 Bridge (com.redhat.service.bridge.manager.models.Bridge)4 Processor (com.redhat.service.bridge.manager.models.Processor)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)3 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2 Topic (com.openshift.cloud.api.kas.auth.models.Topic)2 InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)2 Work (com.redhat.service.bridge.manager.models.Work)2 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)2 Work (com.redhat.service.smartevents.manager.models.Work)2 ZonedDateTime (java.time.ZonedDateTime)2 Transactional (javax.transaction.Transactional)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2