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

[CORE-3184] schema registry - json compatibility checks for objects #19893

Conversation

andijcr
Copy link
Contributor

@andijcr andijcr commented Jun 19, 2024

  • adds support for {"type": "number", "multipleOf": 1.1} -> {"type": "number", "multipleOf": 2.2}
    • compute the reminder and ensure it's close to 0
  • adds minimal support for "not": this is needed to support "additionalProperties", but the implementation is overly restrictive, requiring "not" to be present in both schemas
  • adds support for "type": "object". this check is likely to recurse on the various subschemas

Fixes https://redpandadata.atlassian.net/browse/CORE-4218
Fixes https://redpandadata.atlassian.net/browse/CORE-3184

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

  • none

support non-integer values for "multipleOf" by checking that the
reminder of newer["multipleOf"]/older["multipleOf"] is close to 0.0
@andijcr andijcr force-pushed the feat/core-3184/schema_registry_objects branch from 481db4a to 0aa7778 Compare June 19, 2024 16:52
andijcr added 2 commits June 21, 2024 15:52
force a reformat, so that next commit is only the new test case
the check is overly strict, as it requires for "not" to be present in
both or neither.

In principle a missing "not" can be intepreted as having a default value of false,
but requiring an explicit "not" is simpler
@andijcr andijcr force-pushed the feat/core-3184/schema_registry_objects branch from d1fc64b to 43daaa4 Compare June 21, 2024 20:37
@andijcr andijcr marked this pull request as ready for review June 21, 2024 20:42
@andijcr andijcr requested review from BenPope, pgellert and a team June 21, 2024 20:42
@vbotbuildovich
Copy link
Collaborator

new failures in https://buildkite.com/redpanda/redpanda/builds/50530#01903cc8-b990-4d58-838d-4cee7a533b29:

"rptest.tests.raft_availability_test.RaftAvailabilityTest.test_leadership_transfer"

@vbotbuildovich
Copy link
Collaborator

@andijcr
Copy link
Contributor Author

andijcr commented Jun 24, 2024

failure unrelated, as this pr is not yet wired in

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.

Very nice,

I think a lot of the loops might be a bit clearer with std::ranges::all_of, but I'll leave that up to you.

src/v/pandaproxy/schema_registry/json.cc Outdated Show resolved Hide resolved
src/v/pandaproxy/schema_registry/json.cc Outdated Show resolved Hide resolved
}

return older_it->value;
}();
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 invocation can be deferred so that it's not called if it's not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, done

pgellert
pgellert previously approved these changes Jun 24, 2024
Copy link
Contributor

@pgellert pgellert left a comment

Choose a reason for hiding this comment

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

lgtm

andijcr added 7 commits June 24, 2024 17:22
used in the next set of commits, to implement is_object_superset

the first three define json::Value const& for a "true" and a "false"
schema, these will be useful while checking "additionalProperties" for a
"type": "object"

the last two are getter for array and object that produce an empty value
if the property does not exists. useful to streamline the implementation
implement "minProperties" "maxProperties" compat check for "type":"object"
this subcheck is for "additionalProperties", it will recurse if either
older/newer is a schema and check compatibility.
sub check for "type": "object" on "properties". for each property in
newer, check compatibility against the same property in older, or
against the matching patternProperty in older, or against
additionalProperties in older
subcheck for "type": "object" "patternProperties".

the check is toensure that no new pattern are introduced, and that the
schemas are compatible
final sub-check for "type": "object" "required" field.

the check only look at "required" values that are defined in the
"properties" map.
@andijcr andijcr force-pushed the feat/core-3184/schema_registry_objects branch from 43daaa4 to 1eab55b Compare June 24, 2024 15:26
@andijcr
Copy link
Contributor Author

andijcr commented Jun 24, 2024

force push: reviews comments

I think a lot of the loops might be a bit clearer with std::ranges::all_of, but I'll leave that up to you.

I'll take a look and convert loops in the next PR for array support

@andijcr andijcr requested review from pgellert and BenPope June 24, 2024 15:29
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.

LGTM

@andijcr
Copy link
Contributor Author

andijcr commented Jun 25, 2024

only issue is in debug

Module: rptest.tests.crl_test
Class:  CertificateRevocationTest
Method: test_pp_api
RuntimeError('Expected an exception!')
Traceback (most recent call last):
  File "/opt/.ducktape-venv/lib/python3.10/site-packages/ducktape/tests/runner_client.py", line 184, in _do_run
    data = self.run_test()
  File "/opt/.ducktape-venv/lib/python3.10/site-packages/ducktape/tests/runner_client.py", line 276, in run_test
    return self.test_context.function(self.test)
  File "/root/tests/rptest/services/cluster.py", line 105, in wrapped
    r = f(self, *args, **kwargs)
  File "/root/tests/rptest/tests/crl_test.py", line 188, in test_pp_api
    with expect_exception((requests.exceptions.SSLError,
  File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/root/tests/rptest/util.py", line 309, in expect_exception
    raise RuntimeError("Expected an exception!")
RuntimeError: Expected an exception!

it shouldn't be caused by this pr, but after a quick search i can't find this failure in the tracker on in other nightly runs. rerunning this test

@andijcr
Copy link
Contributor Author

andijcr commented Jun 25, 2024

/ci-repeat 3 skip-unit dt-repeat=10 test/rptest/tests/crl_test.py::CertificateRevocationTest.test_pp_api

@andijcr
Copy link
Contributor Author

andijcr commented Jun 25, 2024

/ci-repeat 3 skip-redpanda-build skip-unit dt-repeat=10 tests/rptest/tests/crl_test.py::CertificateRevocationTest.test_pp_api

@andijcr
Copy link
Contributor Author

andijcr commented Jun 25, 2024

filed a ticket for the failure #20133 , seems unrelated

@michael-redpanda
Copy link
Contributor

Confirmed this was the only CI failure. Ticket created. Not cuased by this PR.

@michael-redpanda michael-redpanda merged commit eac1a02 into redpanda-data:dev Jun 25, 2024
14 of 18 checks passed
@andijcr andijcr deleted the feat/core-3184/schema_registry_objects branch June 25, 2024 16:47
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.

5 participants