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

Add support for Confluent Schema Registry + restructure schema registry extensions #24526

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

alesj
Copy link
Contributor

@alesj alesj commented Mar 24, 2022

No description provided.

@quarkus-bot

This comment was marked as resolved.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@alesj alesj force-pushed the i19277 branch 2 times, most recently from 6a132e4 to 2e11c97 Compare March 25, 2022 10:10
@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@geoand geoand changed the title Set Ccompat url as default registry url when Confluent serde is on th… Set compat url as default registry url when Confluent serde is on the classpath Mar 28, 2022
Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

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

Documentation needs to be updated too:

  • Avro doc
  • Apicurio dev service doc


// Confluent API compatibility support -- TODO

reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false,
Copy link
Member

Choose a reason for hiding this comment

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

wondering if we need to add a flag to enable/disable this.

Copy link
Member

Choose a reason for hiding this comment

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

Typically, guarded with isCcompat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this actually even needed?
Since the IT (native) test worked before I added this ...

I just added this not to forget, and was hoping IT (native) test would expose all the missing stuff ...

Copy link
Member

Choose a reason for hiding this comment

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

Actually, that's a good question. What happens if we include in the native image classes that are not available in the classpath. Would that fail? I don't remember... (that's what I'm trying to prevent).

Copy link
Contributor Author

@alesj alesj Mar 29, 2022

Choose a reason for hiding this comment

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

Looking at KafkaProcessor, all these registrations are guarded by try/catch on the CNFE, with a previous try to load a class from the lib it's trying to support.
So maybe this try/catch is missing / needed here as well?

@@ -118,7 +120,21 @@ public void run() {
}

private String getRegistryUrlConfig(String baseUrl) {
return baseUrl + "/apis/registry/v2";
if (isCcompat()) {
Copy link
Member

Choose a reason for hiding this comment

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

I know that ccompat is what is used by apicurio, but maybe let's say: isUsingConfluentCompatibility() (I've found ccompat to be confusing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I remember we used "Confluent" before in the Apicurio, but then rather went with ccompat.
I'm OK with your isUsingConfluentCompatibility.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 28, 2022

IMHO, adding support for Confluent Avro serde to the Apicurio Registry Avro serde extension is a wrong way to do this. That way, you will always have both serdes on the classpath (unless the user explicitly excludes the Apicurio Registry Avro serde from the extension dependency, which is hardly idiomatic, because support of that serde library is the main purpose of the extension).

What we could/should do is:

  1. Separate the Apicurio Registry dev service from the Avro extension into something like apicurio-registry-base. That's what we always intended to do, except we thought that would be when we add support for Apicurio Registry Protobuf serde or something like that :-)
  2. Add an extension for Confluent. That would be somewhat confusing, because that extension can't really bring in the serde library, as it's not in Maven Central, but at least it makes the intent very clear and can even validate that the serde is present. This extension could then use the Apicurio Registry dev service (and configure the ccompat endpoint), or it could use Karapace perhaps, or do something completely different. I guess using the Apicurio Registry makes most sense.

@alesj
Copy link
Contributor Author

alesj commented Mar 28, 2022

That way, you will always have both serdes on the classpath (unless the user explicitly excludes the Apicurio Registry Avro serde from the extension dependency, which is hardly idiomatic, because support of that serde library is the main purpose of the extension).

Ah, true ... yeah, then we need a proper split ...

That would be somewhat confusing, because that extension can't really bring in the serde library, as it's not in Maven Central

Why is this - not in Maven Central - a problem?

@Ladicek
Copy link
Contributor

Ladicek commented Mar 28, 2022

That would be somewhat confusing, because that extension can't really bring in the serde library, as it's not in Maven Central

Why is this - not in Maven Central - a problem?

I'm not entirely sure if it is possible for extensions to bring dependencies from another Maven repo, perhaps it is. I'm pretty sure we don't really want them to, because of effects on supply chain security and build stability (and downstreams who rebuild Quarkus would also not be particularly pleased I'm sure). But if @gsmet would be fine with it, so would I :-)

@alesj
Copy link
Contributor Author

alesj commented Mar 28, 2022

unless the user explicitly excludes the Apicurio Registry Avro serde from the extension dependency, which is hardly idiomatic, because support of that serde library is the main purpose of the extension

@Ladicek you mean that reflection support in ApicurioRegistryAvroProcessor?
As otherwise I fail to see where some extra value wrt serdes is really added ...

Otoh, wrt reflection support in ApicurioRegistryAvroProcessor ... I can see KafkaAvroIT passing for Confluent serde classes,
yet they are not registered in ApicurioRegistryAvroProcessor ... or am I missing something obvious?

@Ladicek
Copy link
Contributor

Ladicek commented Mar 28, 2022

Ah ah, now I remember -- we actually register Confluent classes for reflection elsewhere, see KafkaProcessor in the kafka-client extension.

@ozangunalp
Copy link
Contributor

@Ladicek was there a specific reason for the apicurio-registry-avro extension to not to have kafka-client dependency ?

@Ladicek
Copy link
Contributor

Ladicek commented Mar 28, 2022

I can't remember one, you just don't use apicurio-registry-avro without also using another extension that transitively brings kafka-client.

@ozangunalp
Copy link
Contributor

Separate the Apicurio Registry dev service from the Avro extension into something like apicurio-registry-base. That's what we always intended to do, except we thought that would be when we add support for Apicurio Registry Protobuf serde or something like that :-)

BTW this change should also work for confluent kafka protobuf serializer when we add support for protobuf serde. So I think this would be included in apicurio-registry-base.

@alesj
Copy link
Contributor Author

alesj commented Apr 7, 2022

OK, tests passed ... feedback on the restructure (before I dig into protobuf / json) ?

@ozangunalp
Copy link
Contributor

Yes the restructuring looks good to me.

@Ladicek
Copy link
Contributor

Ladicek commented Apr 11, 2022

Sorry it took me so long to get to this. The PR is rather complex, so I had to look at it in my IDE.

The general idea of the restructuring sounds good to me. As in, to have something like this:

  • schema registry parent POM
    • dev service
      • deployment
      • runtime
    • Apicurio parent POM
      • common
        • deployment
        • runtime
      • avro
        • deployment
        • runtime
    • Confluent parent POM
      • common
        • deployment
        • runtime
      • avro
        • deployment
        • runtime

The dev service would use Apicurio Registry, but that's an implementation detail. Then, apicurio / common would provide basic support for Apicurio serdes, while apicurio / avro would depend on apicurio / common and add support for Apicurio Avro serde. Same thing for confluent.

However, the present PR uses very confusing naming (apicurio-registry-confluent-what?!). Also, some classes were moved incorrectly in my opinion (the service binding support is present in the dev service? That can't be correct).

I took the liberty to restructure everything once again. The structure I outlined above looks physically like this:

  • extensions/schema-registry: quarkus-schema-registry-parent
    • devservice: quarkus-schema-registry-devservice-parent
      • deployment: quarkus-schema-registry-devservice-deployment
      • runtime: quarkus-schema-registry-devservice
    • apicurio: quarkus-apicurio-registry-parent
      • common: quarkus-apicurio-registry-common-parent
        • deployment: quarkus-apicurio-registry-common-deployment
        • runtime: quarkus-apicurio-registry-common
      • avro: quarkus-apicurio-registry-avro-parent
        • deployment: quarkus-apicurio-registry-avro-deployment
        • runtime: quarkus-apicurio-registry-avro
    • confluent: quarkus-confluent-registry-parent
      • common: quarkus-confluent-registry-common-parent
        • deployment: quarkus-confluent-registry-common-deployment
        • runtime: quarkus-confluent-registry-common
      • avro: quarkus-confluent-registry-avro-parent
        • deployment: quarkus-confluent-registry-avro-deployment
        • runtime: quarkus-confluent-registry-avro

Here's a branch with 1 more commit that restructures everything once more: https://github.com/Ladicek/quarkus/commits/schema-registry-restructured

And here's a branch where the 2 commits from previous branch are squashed: https://github.com/Ladicek/quarkus/commits/schema-registry-restructured-squashed

One question: the changes in integration-tests/kafka-avro-apicurio2 that move from QuarkusTestResourceLifecycleManager to dev services are intentional, to test the dev service stuff, or the QuarkusTestResourceLifecycleManager approach didn't work anymore?

@alesj
Copy link
Contributor Author

alesj commented Apr 14, 2022

@Ladicek yeah, good call and restructuring on the names

the service binding support is present in the dev service?

Yeah, that one I didn't know where it fits best.
Did you move it appropriately now?

move from QuarkusTestResourceLifecycleManager

There was an issue with enabled/disabled dev service, which I wasn't able to override from test code.
While fixing that, I didn't see a reason why not to use and test dev service at the same time.
So I simply removed it, and handled that AvroCreator accordingly.

I guess if there are no other issues, we're good to merge?

@ozangunalp
Copy link
Contributor

Maybe we should consider changing this PRs title and description?

@Ladicek
Copy link
Contributor

Ladicek commented Apr 14, 2022

I moved the service binding thing into apicurio-common, which I think is the right place, but I don't know anything about it. @ozangunalp or @cescoffier, is there a way (I don't dare saying "reasonably simple", though that's what I wish for...) to test the service binding stuff?

Also, I didn't push my changes to this PR. @alesj if you agree with my changes, feel free to update this PR, or I can do that too.

@ozangunalp
Copy link
Contributor

@Ladicek I think also that apicurio-common is the right place for the service binding config converter. I honestly don't know how to test it. The whole thing is dependent on the service type you want to bind. The service type "serviceregistry" provides those mapped keys (I don't know by which spec or convention) and it works until someone changes something.

Overall I am thinking that we should not need to do this conversion and service binding resource should also contain the mapping for the application. But I am not that deep in service binding to understand if it is possible.

@alesj
Copy link
Contributor Author

alesj commented Apr 14, 2022

Maybe we should consider changing this PRs title and description?

Sure.
But since @Ladicek is gonna create a new PR anyway, we can just fix it there.

@alesj
Copy link
Contributor Author

alesj commented Apr 14, 2022

or I can do that too.

Yeah, go ahead.
No need to complicate things.

@Ladicek Ladicek changed the title Set compat url as default registry url when Confluent serde is on the classpath Add support for Confluent Schema Registry + restructure schema registry extensions Apr 14, 2022
@Ladicek
Copy link
Contributor

Ladicek commented Apr 14, 2022

Pushed and changed PR title.

@Ladicek
Copy link
Contributor

Ladicek commented Apr 21, 2022

Hi @ozangunalp @cescoffier @geoand @iocanel, could you please advise on how to test (manually I guess?) the Apicurio Registry service binding stuff? I don't know who authored that and I have exactly zero experience with service binding, but I figured some of you might know :-)

@geoand
Copy link
Contributor

geoand commented Apr 21, 2022

No idea about apicurio, but an integration test for service binding for JDBC can be found at: https://github.com/quarkusio/quarkus/tree/2.8.1.Final/integration-tests/kubernetes-service-binding-jdbc

I assume something similar can be done for apicurio

@ozangunalp
Copy link
Contributor

@Ladicek @geoand I don't think that kind of IT will actually test the Apicurio config mapping. It effectively tests that a service binding root directory is transformed to config, but that's it.

It seems like those magical keys in ServiceRegistryBindingConverter are provided by the RHOAS Service Registry Operator. I could find a short documentation here: https://github.com/redhat-developer/app-services-operator/blob/main/docs/service_binding.adoc

I recently did a (manual) test and can confirm that the converter for Apicurio works as intended.
On another note, the ServiceBinding resources we generate in Quarkus did not work OOTB with the RHOAS SBO.
I'll create a PR to give the possibility to generate ServiceBindings that play well with RHOAS SBO.

@Ladicek
Copy link
Contributor

Ladicek commented Apr 22, 2022

In that case, I guess I'll just rebase this PR and we can merge it...

@Ladicek
Copy link
Contributor

Ladicek commented Apr 22, 2022

@ozangunalp could you please take a look too? Thanks!

@ozangunalp
Copy link
Contributor

@Ladicek I am on it!

Copy link
Contributor

@ozangunalp ozangunalp left a comment

Choose a reason for hiding this comment

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

LGTM! @Ladicek I also checked that the service binding converter for apicurio still works :)

@Ladicek Ladicek dismissed cescoffier’s stale review April 22, 2022 16:10

I believe this was addressed

@Ladicek
Copy link
Contributor

Ladicek commented Apr 22, 2022

Thank you!

I'm a little scared, but the big green button is so tempting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants