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

schema_registry/proto: Accept protobuf as an encoded file descriptor #3663

Merged

Conversation

BenPope
Copy link
Member

@BenPope BenPope commented Jan 31, 2022

Cover letter

Schema registry supports the .proto version of protobuf, but the serializers send them as encoded protobuf descriptors.

This PR accepts the encoded form of a protobuf definition.

Fix #3633

Release notes

Improvements

  • Schema Registry: Support protobuf encoded protobuf schema for compatibility with Protobuf Serializers.

Signed-off-by: Ben Pope <ben@vectorized.io>
Signed-off-by: Ben Pope <ben@vectorized.io>
Support decoding a protobuf FileDescriptor as encoded protobuf.

Fix redpanda-data#3633

Signed-off-by: Ben Pope <ben@vectorized.io>
@CLAassistant
Copy link

CLAassistant commented Jan 31, 2022

CLA assistant check
All committers have signed the CLA.

Signed-off-by: Ben Pope <ben@vectorized.io>
Signed-off-by: Ben Pope <ben@vectorized.io>
@BenPope BenPope force-pushed the schema-regstry-protobuf-file-descriptor branch from 12602b1 to dae8b89 Compare January 31, 2022 19:47
@BenPope BenPope self-assigned this Jan 31, 2022
@BenPope BenPope added area/schema-registry Schema Registry service within Redpanda kind/enhance New feature or request labels Jan 31, 2022
Copy link
Contributor

@NyaliaLui NyaliaLui left a comment

Choose a reason for hiding this comment

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

lgtm. My only comment is a nit

"""
Verify basic serialization client
"""
protocols = [SchemaType.AVRO, SchemaType.PROTOBUF]
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a good candidate for the @matrix decorator in ducktape that way you don't need a loop over 2 values.
I don't know if @matrix would work with Enums though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice idea. It's a bit of a trade-off with execution time. Happy to give it a go.

Copy link
Member

Choose a reason for hiding this comment

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

This could be a good candidate for the @matrix decorator in ducktape that way you don't need a loop over 2 values.

yeh

Nice idea. It's a bit of a trade-off with execution time. Happy to give it a go.

another benefit of using @matrix is that the test framework treats the points parameter space as separate tests. so if one particular point fails ducktape can report the test configuration rather than forcing dev to go look through logs to see which configuration failed.

from_dict=lambda d, _: AvroPayload(d['val'])),
SchemaType.PROTOBUF:
ProtobufDeserializer(ProtobufPayloadClass)
}[self.schema_type]
Copy link
Contributor

Choose a reason for hiding this comment

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

clever use of dict

Copy link
Member Author

Choose a reason for hiding this comment

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

Python is not my strong point, is there a clearer alternative?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm by no means a python expert but you could store the dict as a variable.
I like your way though.

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 think the difference would be that the serializers would be shared for multiple calls, although it could easily be made a dict of factories.

Copy link
Member

@dotnwat dotnwat Feb 3, 2022

Choose a reason for hiding this comment

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

if .. elif ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

https://www.python.org/dev/peps/pep-0636/ in Python 3.10.

oh that's nice. looks like 3.10 might have made it into fedora 35 so it's getting out there.

@NyaliaLui
Copy link
Contributor

It doesn't look like the CI failure is related to this PR

@BenPope BenPope merged commit 0773cf9 into redpanda-data:dev Feb 2, 2022
Comment on lines 190 to 192
co_return co_await build_file_with_refs(dp, store, std::move(schema));
co_return co_await build_file_with_refs(dp, store, schema);
} catch (const exception& e) {
vlog(plog.warn, "Failed to decode schema: {}", e.what());
Copy link
Member

Choose a reason for hiding this comment

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

great catch!

from_dict=lambda d, _: AvroPayload(d['val'])),
SchemaType.PROTOBUF:
ProtobufDeserializer(ProtobufPayloadClass)
}[self.schema_type]
Copy link
Member

Choose a reason for hiding this comment

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

https://www.python.org/dev/peps/pep-0636/ in Python 3.10.

oh that's nice. looks like 3.10 might have made it into fedora 35 so it's getting out there.

"""
Verify basic serialization client
"""
protocols = [SchemaType.AVRO, SchemaType.PROTOBUF]
Copy link
Member

Choose a reason for hiding this comment

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

This could be a good candidate for the @matrix decorator in ducktape that way you don't need a loop over 2 values.

yeh

Nice idea. It's a bit of a trade-off with execution time. Happy to give it a go.

another benefit of using @matrix is that the test framework treats the points parameter space as separate tests. so if one particular point fails ducktape can report the test configuration rather than forcing dev to go look through logs to see which configuration failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redpanda area/schema-registry Schema Registry service within Redpanda kind/enhance New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema registry protobuf compatibility issue
4 participants