Search in sources :

Example 1 with ConnectorDeployment

use of org.bf2.cos.fleet.manager.model.ConnectorDeployment in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class ConnectorDeploymentProvisioner method provision.

public void provision(ConnectorDeployment deployment) {
    final String uow = uid();
    LOGGER.info("Got cluster_id: {}, connector_id: {}, deployment_id: {}, resource_version: {}, uow: {}", fleetShard.getClusterId(), deployment.getSpec().getConnectorId(), deployment.getId(), deployment.getMetadata().getResourceVersion(), uow);
    // TODO: cache cluster
    final ManagedConnectorCluster cluster = fleetShard.getOrCreateManagedConnectorCluster();
    final ManagedConnector connector = createManagedConnector(uow, deployment, cluster);
    final Secret secret = createManagedConnectorSecret(uow, deployment, connector);
    LOGGER.info("CreateOrReplace - uow: {}, managed_connector: {}/{}, managed_connector_secret: {}/{}", uow, connector.getMetadata().getNamespace(), connector.getMetadata().getName(), secret.getMetadata().getNamespace(), secret.getMetadata().getName());
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ManagedConnectorCluster(org.bf2.cos.fleetshard.api.ManagedConnectorCluster) ManagedConnector(org.bf2.cos.fleetshard.api.ManagedConnector)

Example 2 with ConnectorDeployment

use of org.bf2.cos.fleet.manager.model.ConnectorDeployment in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class ConnectorDeploymentProvisioner method provisionConnectors.

private void provisionConnectors(Collection<ConnectorDeployment> deployments) {
    for (ConnectorDeployment deployment : deployments) {
        this.recorder.record(() -> provision(deployment), Tags.of(TAG_DEPLOYMENT_ID, deployment.getId()), e -> {
            LOGGER.error("Failure while trying to provision connector deployment: id={}, revision={}", deployment.getId(), deployment.getMetadata().getResourceVersion(), e);
            try {
                MetaV1Condition condition = new MetaV1Condition();
                condition.setType(Conditions.TYPE_READY);
                condition.setStatus(Conditions.STATUS_FALSE);
                condition.setReason(Conditions.FAILED_TO_CREATE_OR_UPDATE_RESOURCE_REASON);
                condition.setMessage(e.getMessage());
                ConnectorDeploymentStatus status = new ConnectorDeploymentStatus();
                status.setResourceVersion(deployment.getMetadata().getResourceVersion());
                status.addConditionsItem(condition);
                fleetManager.updateConnectorStatus(fleetShard.getClusterId(), deployment.getId(), status);
            } catch (Exception ex) {
                LOGGER.warn("Error wile reporting failure to the control plane", e);
            }
            fleetShard.getConnectorCluster().ifPresent(cc -> {
                fleetShard.broadcast("Warning", "FailedToCreateOrUpdateResource", String.format("Unable to create or update deployment %s, revision: %s, reason: %s", deployment.getId(), deployment.getMetadata().getResourceVersion(), e.getMessage()), cc);
            });
        });
    }
}
Also used : ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) MetaV1Condition(org.bf2.cos.fleet.manager.model.MetaV1Condition) ConnectorDeploymentStatus(org.bf2.cos.fleet.manager.model.ConnectorDeploymentStatus)

Example 3 with ConnectorDeployment

use of org.bf2.cos.fleet.manager.model.ConnectorDeployment in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class ConnectorDeploymentProvisioner method provision.

public void provision(ConnectorDeployment deployment) {
    final String uow = uid();
    LOGGER.info("Got cluster_id: {}, namespace_d: {}, connector_id: {}, deployment_id: {}, resource_version: {}, uow: {}", fleetShard.getClusterId(), deployment.getSpec().getNamespaceId(), deployment.getSpec().getConnectorId(), deployment.getId(), deployment.getMetadata().getResourceVersion(), uow);
    final ManagedConnector connector = createManagedConnector(uow, deployment, null);
    final Secret secret = createManagedConnectorSecret(uow, deployment, connector);
    LOGGER.info("CreateOrReplace - uow: {}, connector: {}/{}, secret: {}/{}", uow, connector.getMetadata().getNamespace(), connector.getMetadata().getName(), secret.getMetadata().getNamespace(), secret.getMetadata().getName());
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ManagedConnector(org.bf2.cos.fleetshard.api.ManagedConnector)

Example 4 with ConnectorDeployment

use of org.bf2.cos.fleet.manager.model.ConnectorDeployment in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class SyncTestSupport method deploymentList.

public static ObjectNode deploymentList(ConnectorDeployment... deployments) {
    var items = new ConnectorDeploymentList();
    items.page(1);
    items.size(deployments.length);
    items.total(deployments.length);
    for (ConnectorDeployment deployment : deployments) {
        items.addItemsItem(deployment);
    }
    return Serialization.jsonMapper().convertValue(items, ObjectNode.class);
}
Also used : ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)

Example 5 with ConnectorDeployment

use of org.bf2.cos.fleet.manager.model.ConnectorDeployment in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class FleetManagerClient method getDeployments.

public void getDeployments(long gv, Consumer<Collection<ConnectorDeployment>> consumer) {
    RestClientHelper.run(() -> {
        LOGGER.debug("polling deployment with gv: {}", gv);
        final AtomicInteger counter = new AtomicInteger();
        final List<ConnectorDeployment> items = new ArrayList<>();
        for (int i = 1; i < Integer.MAX_VALUE; i++) {
            ConnectorDeploymentList list = controlPlane.getConnectorDeployments(config.cluster().id(), Integer.toString(i), null, gv);
            if (list == null || list.getItems() == null || list.getItems().isEmpty()) {
                LOGGER.info("No connectors for cluster {}", config.cluster().id());
                break;
            }
            items.clear();
            items.addAll(list.getItems());
            items.sort(Comparator.comparingLong(d -> d.getMetadata().getResourceVersion()));
            consumer.accept(items);
            if (counter.addAndGet(items.size()) >= list.getTotal()) {
                break;
            }
        }
    });
}
Also used : ConnectorDeploymentStatus(org.bf2.cos.fleet.manager.model.ConnectorDeploymentStatus) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList) Logger(org.slf4j.Logger) Collection(java.util.Collection) ConnectorClusterStatus(org.bf2.cos.fleet.manager.model.ConnectorClusterStatus) LoggerFactory(org.slf4j.LoggerFactory) FleetShardSyncConfig(org.bf2.cos.fleetshard.sync.FleetShardSyncConfig) ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ConnectorNamespaceStatus(org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Serialization(io.fabric8.kubernetes.client.utils.Serialization) ConnectorNamespaceList(org.bf2.cos.fleet.manager.model.ConnectorNamespaceList) ApplicationScoped(javax.enterprise.context.ApplicationScoped) UriBuilder(javax.ws.rs.core.UriBuilder) Comparator(java.util.Comparator) RestClientBuilder(org.eclipse.microprofile.rest.client.RestClientBuilder) ManagedConnector(org.bf2.cos.fleetshard.api.ManagedConnector) ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)

Aggregations

ConnectorDeployment (org.bf2.cos.fleet.manager.model.ConnectorDeployment)11 ManagedConnector (org.bf2.cos.fleetshard.api.ManagedConnector)8 Secret (io.fabric8.kubernetes.api.model.Secret)6 FleetShardSyncConfig (org.bf2.cos.fleetshard.sync.FleetShardSyncConfig)5 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)4 FleetManagerClient (org.bf2.cos.fleetshard.sync.client.FleetManagerClient)4 ConnectorDeploymentStatus (org.bf2.cos.fleet.manager.model.ConnectorDeploymentStatus)3 KafkaConnectionSettings (org.bf2.cos.fleet.manager.model.KafkaConnectionSettings)3 SchemaRegistryConnectionSettings (org.bf2.cos.fleet.manager.model.SchemaRegistryConnectionSettings)3 FleetShardClient (org.bf2.cos.fleetshard.sync.client.FleetShardClient)3 ConnectorDeploymentProvisioner (org.bf2.cos.fleetshard.sync.resources.ConnectorDeploymentProvisioner)3 Test (org.junit.jupiter.api.Test)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)2 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)2 Collection (java.util.Collection)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 ConnectorDeploymentAllOfMetadata (org.bf2.cos.fleet.manager.model.ConnectorDeploymentAllOfMetadata)2 ConnectorDeploymentList (org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)2