use of org.bf2.cos.fleetshard.api.Version in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class DeploymentManager method deployStrimziKafka.
private KafkaContainer<?> deployStrimziKafka() {
LOGGER.info("Deploying Strimzi Kafka container");
class StrimziPlainKafkaContainer extends StrimziKafkaContainer implements KafkaContainer<StrimziKafkaContainer> {
StrimziPlainKafkaContainer(String version) {
super(version);
}
}
String imageTag = System.getProperty("strimzi-kafka.tag");
var container = new StrimziPlainKafkaContainer(imageTag).withLabels(Collections.singletonMap("test-ident", Environment.TEST_CONTAINER_LABEL)).withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("systemtests.plain-kafka"), true)).withCreateContainerCmdModifier(cmd -> cmd.withName(name("plain-kafka"))).withNetwork(testNetwork);
container.start();
return (KafkaContainer<?>) container;
}
use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaControllerTest method testWrongVersions.
@Test
void testWrongVersions() throws InterruptedException {
ManagedKafka mk = ManagedKafka.getDummyInstance(1);
mk.getMetadata().setUid(UUID.randomUUID().toString());
mk.getMetadata().setGeneration(1l);
mk.getMetadata().setResourceVersion("1");
// create
Context<ManagedKafka> context = Mockito.mock(Context.class);
Mockito.when(context.getEvents()).thenReturn(new EventList(Arrays.asList(new CustomResourceEvent(Action.ADDED, mk, null))));
StrimziManager strimziManager = Mockito.mock(StrimziManager.class);
Mockito.when(strimziManager.getVersionLabel()).thenReturn("managedkafka.bf2.org/strimziVersion");
QuarkusMock.installMockForType(strimziManager, StrimziManager.class);
mkController.createOrUpdateResource(mk, context);
ManagedKafkaCondition condition = mk.getStatus().getConditions().get(0);
assertEquals(ManagedKafkaCondition.Reason.Error.name(), condition.getReason());
assertEquals("The requested Strimzi version strimzi-cluster-operator.v0.23.0 is not supported", condition.getMessage());
Mockito.when(strimziManager.getStrimziVersion("strimzi-cluster-operator.v0.23.0")).thenReturn(new StrimziVersionStatusBuilder().withVersion(mk.getSpec().getVersions().getStrimzi()).withKafkaVersions("3.0.0").build());
mkController.createOrUpdateResource(mk, context);
condition = mk.getStatus().getConditions().get(0);
assertEquals(ManagedKafkaCondition.Reason.Error.name(), condition.getReason());
assertEquals("The requested Kafka version 2.7.0 is not supported by the Strimzi version strimzi-cluster-operator.v0.23.0", condition.getMessage());
}
use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method setStrimziPendingInstallationVersions.
/**
* Notify the strimzi manager of pending versions.
* @param pendingVersions
* @return true if the pending state has changed
*/
public boolean setStrimziPendingInstallationVersions(List<String> pendingVersions) {
if (!Collections.disjoint(strimziPendingInstallationVersions.keySet(), pendingVersions)) {
return false;
}
log.infof("Notified of pending strimzi versions %s", pendingVersions);
ConcurrentHashMap<String, StrimziVersionStatus> next = new ConcurrentHashMap<>();
for (String version : pendingVersions) {
StrimziVersionStatus existing = strimziVersions.get(version);
if (existing != null) {
next.put(version, new StrimziVersionStatusBuilder(existing).withReady(false).build());
} else {
next.put(version, EMPTY_STATUS);
}
}
this.strimziPendingInstallationVersions = next;
informerManager.resyncManagedKafkaAgent();
return true;
}
use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method currentStrimziVersion.
/**
* Returns the current Strimzi version for the Kafka instance
* It comes directly from the Kafka custom resource label or from the ManagedKafka in case of creation
*
* @param managedKafka ManagedKafka instance
* @return current Strimzi version for the Kafka instance
*/
public String currentStrimziVersion(ManagedKafka managedKafka) {
Kafka kafka = cachedKafka(managedKafka);
// on first time Kafka resource creation, we take the Strimzi version from the ManagedKafka resource spec
String kafkaStrimziVersion = kafka != null && kafka.getMetadata().getLabels() != null && kafka.getMetadata().getLabels().containsKey(this.versionLabel) ? kafka.getMetadata().getLabels().get(this.versionLabel) : managedKafka.getSpec().getVersions().getStrimzi();
log.debugf("currentStrimziVersion = %s", kafkaStrimziVersion);
return kafkaStrimziVersion;
}
use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method updateStatus.
private void updateStatus() {
List<StrimziVersionStatus> versions = new ArrayList<>(this.strimziVersions.values());
// create the Kafka informer only when a Strimzi bundle is installed (aka at least one available version)
if (!versions.isEmpty()) {
informerManager.createKafkaInformer();
}
ManagedKafkaAgent resource = agentClient.getByName(agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
if (resource != null && resource.getStatus() != null) {
List<StrimziVersionStatus> existing = resource.getStatus().getStrimzi();
if (!versions.equals(existing)) {
log.debugf("Updating Strimzi versions %s", versions);
resource.getStatus().setStrimzi(versions);
agentClient.replaceStatus(resource);
// version changes should sync the managed kafkas
if (existing == null || !toVersionKeySet(versions).equals(toVersionKeySet(existing))) {
informerManager.resyncManagedKafka();
}
}
}
}
Aggregations