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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE-1507] SR: Add support for ?verbose compatibility checks #18332

Draft
wants to merge 17 commits into
base: dev
Choose a base branch
from

Conversation

oleiman
Copy link
Member

@oleiman oleiman commented May 9, 2024

Some side effects of this:

  • In general, this PR keeps existing checks in place but adds reference-compatible error codes and messages to provide human-readable detail.
  • On the protobuf side, this PR introduces a handful of checks that are functionally new (i.e. schemas which were previously considered compatible are no longer so):
    • ONEOF_FIELD_REMOVED
    • MULTIPLE_FIELDS_MOVED_TO_ONEOF
    • REQUIRED_FIELD_{ADDED,REMOVED}
    • FIELD_NAMED_TYPE_CHANGED
    • MESSAGE_REMOVED
      • We already detect some of these (file level) but this PR adds additional checks for nested message definitions
  • Previously our compatibility checks would short circuit, returning a 馃憤 / 馃憥 as soon as a determination is made. Now we want to build up a collection of errors so that users can make all the required changes and avoid repeated checks. To do this, we need to rejigger the structure of the recursion a bit and introduce some new types for collecting errors.
  • We also want to report "path" information about errors (i.e. where in the schema the error occurred), so we need to carry that information through the recursion. I used std::filesystem::path for this as a first pass, but in the end it looks fit for purpose. We could implement something similar if the cost is a concern, but I suspect most of the cost is in storing the path elements themselves, so it may be a wash. It might be nice to just not do this if verbose error tracking is not enabled.

Fixes CORE-1507

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.1.x
  • v23.3.x
  • v23.2.x

Release Notes

Improvements

  • SchemaRegistry: Adds support for the ?verbose parameter on POST /compatibility/subjects/{subject}/versions/{version}

@oleiman
Copy link
Member Author

oleiman commented May 9, 2024

force push move some compatibility code from header

@oleiman
Copy link
Member Author

oleiman commented May 9, 2024

/dt

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented May 9, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/48905#018f5f60-2f1f-49b5-9525-d2010401037a:

"rptest.tests.schema_registry_test.SchemaRegistryBasicAuthTest.test_post_compatibility_subject_version"

new failures in https://buildkite.com/redpanda/redpanda/builds/48905#018f5f51-1de4-47ce-b35c-e447df7d2995:

"rptest.tests.schema_registry_test.SchemaRegistryBasicAuthTest.test_post_compatibility_subject_version"

@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from 2f889eb to cf73462 Compare May 9, 2024 23:06
@oleiman
Copy link
Member Author

oleiman commented May 9, 2024

force push typo

@oleiman
Copy link
Member Author

oleiman commented May 10, 2024

/ci-repeat 1

@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from cf73462 to 7a95322 Compare May 11, 2024 03:08
@oleiman oleiman changed the title SR: Add support for ?verbose compatibility checks [CORE-1507] SR: Add support for ?verbose compatibility checks May 11, 2024
@oleiman oleiman marked this pull request as ready for review May 11, 2024 03:09
assert result_raw.status_code == requests.codes.ok
assert result_raw.json()["is_compatible"] == False

self.logger.debug(
"Check compatibility backward, no default, not verbose")
Copy link
Contributor

@Deflaimun Deflaimun May 13, 2024

Choose a reason for hiding this comment

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

I know this is just a logger but I don't understand what it's supposed to mean...Writing can possibly be improved

Copy link
Member Author

@oleiman oleiman May 13, 2024

Choose a reason for hiding this comment

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

FYI - these are integration tests (i.e. not broker logs), but I can try to make it more clear on the next push.

@oleiman oleiman marked this pull request as draft May 13, 2024 20:48
@oleiman oleiman marked this pull request as draft May 13, 2024 20:48
@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from 7a95322 to 437aecb Compare May 14, 2024 03:33
@oleiman
Copy link
Member Author

oleiman commented May 14, 2024

force push improve commits, tests, remove some junk

@oleiman oleiman marked this pull request as ready for review May 14, 2024 03:36
@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from 437aecb to ee92933 Compare May 14, 2024 04:01
@oleiman
Copy link
Member Author

oleiman commented May 14, 2024

force push remove some cruft

@oleiman oleiman requested review from a team, michael-redpanda and BenPope and removed request for a team May 14, 2024 04:30
Copy link
Member

@BenPope BenPope left a comment

Choose a reason for hiding this comment

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

Partial review up until avro - but plenty of work, hopefully mostly just a rebase of our libavro fork.

src/v/pandaproxy/schema_registry/compatibility.h Outdated Show resolved Hide resolved
src/v/pandaproxy/schema_registry/compatibility.h Outdated Show resolved Hide resolved
src/v/pandaproxy/schema_registry/avro.cc Outdated Show resolved Hide resolved
if (reader.type() == avro::Type::AVRO_ARRAY) {
compat_result.merge(check_compatible(
*reader.leafAt(0), *writer.leafAt(0), p / "items"));
} else if (reader.hasName() && reader.name() != writer.name()) {
Copy link
Member

Choose a reason for hiding this comment

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

This check is too restrictive; it needs to handle aliases. That appears to be a recent addition to libavro, so you're in luck, to some extent.

Copy link
Member

Choose a reason for hiding this comment

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

Does this set of alternatives need to be broken into a set of checks (i.e., drop the else) to record all incompatible checks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Does this set of alternatives need to be broken into a set of checks

Yeah probably. At least this one (checking the name). The strict type checks are mutually exclusive. Maybe you're right actually - we don't lose anything by breaking it all up.

Comment on lines 86 to 87
// ?? - emplace an UNKNOWN error with the current path
compat_result.emplace<avro_incompatibility>(
std::move(p), avro_incompatibility::Type::UNKNOWN);
return compat_result;
Copy link
Member

Choose a reason for hiding this comment

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

More thought required from me, I feel like this is too restrictive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Too restrictive in the sense that

a. we might discover more context later (i.e. short-circuit too soon) OR
b. the schemas might still be compatible.

To (a), that's why I added the extra checks above, so it's possible that there are more!

I do think we're guaranteed to be incompatible here though; as I understand it, Node::resolve is meant to detect "obvious" incompatibilities like scalar type mismatch, etc. Everything below (records, enums, unions) is not detectable by Node::resolve

src/v/pandaproxy/schema_registry/avro.cc Outdated Show resolved Hide resolved
src/v/pandaproxy/schema_registry/avro.cc Outdated Show resolved Hide resolved
@BenPope BenPope self-requested a review May 16, 2024 15:18
@oleiman oleiman marked this pull request as draft May 17, 2024 19:31
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from ee92933 to 371727b Compare May 17, 2024 19:31
@oleiman
Copy link
Member Author

oleiman commented May 17, 2024

force push rebase dev to account for breaking seastar change

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from 371727b to 59d102b Compare May 17, 2024 20:44
@oleiman
Copy link
Member Author

oleiman commented May 17, 2024

force push downcase enums

oleiman added 15 commits May 17, 2024 14:00
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Specifically we reed to enforce the presence of _nested_ message
types. Previously we only checked at file scope.

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Common test code for working with detailed compatibility info about
protobuf and avro schemas.
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
@oleiman oleiman force-pushed the ds/core-1507/verbose-compat-sr branch from 59d102b to 25c8445 Compare May 17, 2024 21:07
@oleiman
Copy link
Member Author

oleiman commented May 17, 2024

/ci-repeat 1

@oleiman
Copy link
Member Author

oleiman commented May 17, 2024

This project is getting deprioritized in favor of FIPS work for at least the next couple weeks. Please direct any inquiries to myself, @aanthony-rp, or @michael-redpanda

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.

None yet

6 participants