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());
}
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);
});
});
}
}
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());
}
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);
}
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;
}
}
});
}
Aggregations