use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaInstanceTest method statusInstallingTrumpsError.
@Test
void statusInstallingTrumpsError() {
ManagedKafka managedKafka = DUMMY_MANAGED_KAFKA;
when(kafkaCluster.getReadiness(managedKafka)).thenReturn(new OperandReadiness(Status.True, Reason.StrimziUpdating, null));
when(canary.getReadiness(managedKafka)).thenReturn(new OperandReadiness(Status.False, Reason.Error, "I'm not well"));
when(adminServer.getReadiness(managedKafka)).thenReturn(new OperandReadiness(Status.False, Reason.Installing, "I'm installing"));
OperandReadiness readiness = kafkaInstance.getReadiness(managedKafka);
assertEquals(Status.False, readiness.getStatus());
assertEquals(Reason.Installing, readiness.getReason());
assertEquals("I'm not well; I'm installing", readiness.getMessage());
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class InstanceProfiler method deployIfNeeded.
private void deployIfNeeded(String name) throws Exception {
ManagedKafka mk = null;
Resource<ManagedKafka> mkResource = kafkaCluster.kubeClient().client().resources(ManagedKafka.class).inNamespace(Constants.KAFKA_NAMESPACE).withName(name);
try {
mk = mkResource.get();
} catch (KubernetesClientException e) {
}
ManagedKafkaDeployment kd = null;
if (mk == null) {
if (!installedProvisioner) {
// TODO: come up with a better resume logic here - it currently has to recreate everything
installedProvisioner = true;
kafkaProvisioner.install();
}
kafkaProvisioner.removeClusters(true);
kd = kafkaProvisioner.deployCluster(name, profilingResult.capacity, profilingResult.config);
} else {
// TODO validate config / capacity
kd = new ManagedKafkaDeployment(mk, kafkaCluster);
kd.start();
}
instanceBootstrap = kd.waitUntilReady();
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaSync method reconcile.
/**
* Final sync processing of the remote vs. local state
*/
void reconcile(String remoteId, String localMetaNamespaceKey) {
ManagedKafka local = null;
if (localMetaNamespaceKey != null) {
// refresh the local
local = lookup.getLocalManagedKafka(localMetaNamespaceKey);
}
ManagedKafka remote = null;
if (remoteId != null) {
// refresh the remote
remote = controlPlane.getDesiredState(remoteId);
}
if (local == null && remote == null) {
// nothing to do
return;
}
String id = null;
if (local != null) {
id = local.getId();
} else {
id = remote.getId();
}
if (id != null) {
NDC.push(ManagedKafkaResourceClient.ID_LOG_KEY + "=" + id);
}
try {
if (local == null) {
if (!remote.getSpec().isDeleted()) {
create(remote);
}
} else if (remote == null) {
if (deleteAllowed(local)) {
delete(local);
}
} else {
if (!Objects.equals(local.getPlacementId(), remote.getPlacementId())) {
log.debugf("Waiting for existing ManagedKafka %s to disappear before attempting next placement", local.getPlacementId());
return;
}
if (specChanged(remote.getSpec(), local)) {
log.debugf("Updating ManagedKafka Spec for %s", Cache.metaNamespaceKeyFunc(local));
ManagedKafkaSpec spec = remote.getSpec();
client.edit(local.getMetadata().getNamespace(), local.getMetadata().getName(), mk -> {
mk.setSpec(spec);
return mk;
});
// the operator will handle it from here
}
}
} finally {
if (id != null) {
NDC.pop();
}
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ControlPlane method getKafkaClusters.
/**
* Get the current list of ManagedKafka clusters from the control plane
* as a blocking call.
* Also updates the cache of desired state ManagedKafka instances. May include
* entries that have not yet been created locally.
*
* @see {@link #getDesiredStates()} to get the full cache, rather than making a
* remote call
*/
public List<ManagedKafka> getKafkaClusters() {
ManagedKafkaList result = controlPlaneClient.getKafkaClusters(id);
result.getItems().forEach((mk) -> addDesiredState(mk));
return result.getItems();
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class PollerTest method exampleManagedKafka.
static ManagedKafka exampleManagedKafka() {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
mk.setId(ID);
return mk;
}
Aggregations