Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(operator): plain kafkasql support #5375

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

jsenko
Copy link
Member

@jsenko jsenko commented Oct 21, 2024

No description provided.

import lombok.*;

@JsonInclude(Include.NON_NULL)
@JsonPropertyOrder({ "env", "host" })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a leftover

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@JsonPropertyDescription("""
Configure KafkaSQL storage.""")
@JsonSetter(nulls = Nulls.SKIP)
private ApicurioRegistry3SpecKafkaSql kafkasql = new ApicurioRegistry3SpecKafkaSql();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, being able to identify the presence of the field checking for null at the kafkasql object level seems useful to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. So the rule is: default value for collections, null for objects? If so we need to update ApicurioRegistry3Spec.

}

private static void applyStrimziResources(boolean delete) {
String text = load("/k8s/examples/kafkasql/strimzi-cluster-operator-0.43.0.yaml");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strimzi-cluster-operator is huge, I think that, in this specific case, we can use the upstream installation mechanism: https://strimzi.io/install/latest.
We can keep an eye on it and, if it starts failing too often, we can revert to dumping resources.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. However, I would prefer downloading a specific version, since we're using Strimzi Java model.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're using Strimzi Java model

that's something we should aim to avoid. No need from our perspective to bind to Strimzi.


@AfterAll
public static void afterAll() throws Exception {
applyStrimziResources(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments here:

  • do we need to explicitly delete resources? something is getting stuck on finalizers?
  • deletion of resources in a namespace should remove detected resources, e.g. we should get from the namespace and remove. The source of truth is the cluster and not the previously applied yaml.

Copy link
Member Author

@jsenko jsenko Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -54,7 +54,7 @@ public enum OperatorDeployment {
private static Operator operator;

@BeforeAll
public static void before() throws Exception {
public static void beforeAll() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: the operator codebase is still early and I don't mind those changes, going forward let's try to minimize those unrelated changes, and, maybe pack them in a "chore" separate PR.
Two reasons:

  • git history -> is easier to follow the history of changes when they are done in isolation
  • review -> it keeps things better scoped

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted. I consider this fine, since it is often easier to fix a small thing immediately if you notice it, rather than trying to remember and create micro PRs. Do you consider it a good practice to track things like these in issues? If so I'll create an issue for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to process for this, just open a PR changing just this bit and we fast-track it.

@@ -0,0 +1,36 @@
apiVersion: kafka.strimzi.io/v1beta2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should those examples resources stay in the test scope?
Do we need them at runtime in the Operator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily in runtime, but my thinking is that we can use those examples in documentation for example, while making sure they are tested. If you have a suggestion on how to better organize this, let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider the test/resources folder, so that they are not going to be bundled with the final JARs

client.resource(kafka).create();

await().ignoreExceptions().until(() -> {
var status = client.resources(Kafka.class).inNamespace(namespace).withName("my-cluster").get()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a check that is not dependent on the Strimzi CR?
E.g. something that should work without code changes also for plain Kafka and RedPanda.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would welcome a specific suggestion/code from you. I added the dependency because:

  • I need to read the status in the test. The alternative is using raw JsonNodes, or assuming what the bootstrapServers value will be, and I don't like either of those much.
  • Our customers are very likely to use Strimzi/AMQ streams, so using it in our tests gives greater confidence it'll work, and provides examples for users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get the status of the ReplicaSet of the Kafka pods, all the checks are, anyhow happening with retries and it should be more than enough to have a stable situation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strimzi does not use ReplicaSet btw.

@@ -89,6 +89,12 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should be able to not tight the setup to Strimzi but keep it more generic.

Copy link
Member

@andreaTP andreaTP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks in great shape now, thanks!

The last bit is to remove the dependency on Strimzi, I can help doing it if required, just let me know 👍

@jsenko
Copy link
Member Author

jsenko commented Oct 24, 2024

This PR looks in great shape now, thanks!

The last bit is to remove the dependency on Strimzi, I can help doing it if required, just let me know 👍

Done.

Copy link
Member

@andreaTP andreaTP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go, nice job!

final var clusterNAme = "my-cluster";

await().ignoreExceptions().untilAsserted(() ->
// Strimzi uses StrimziPodSet instead of ReplicaSet, so we have to check pods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jsenko jsenko force-pushed the operator-kafkasql-plain branch from cbc4ab5 to 1c46f7c Compare October 24, 2024 13:26
@jsenko jsenko enabled auto-merge (rebase) October 24, 2024 13:26
@jsenko jsenko merged commit ef34ecd into Apicurio:main Oct 24, 2024
19 checks passed
@jsenko jsenko deleted the operator-kafkasql-plain branch October 24, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants