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-60] Schema Registry: Support /mode
#17952
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
No functional changes Signed-off-by: Ben Pope <ben@redpanda.com>
Signed-off-by: Ben Pope <ben@redpanda.com>
/mode
/mode
template<> | ||
constexpr std::optional<mode> from_string_view<mode>(std::string_view sv) { | ||
return string_switch<std::optional<mode>>(sv) | ||
.match(to_string_view(mode::import), mode::import) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like how to_string_view gets reused here. nice and clena
auto sub_shard{shard_for(sub)}; | ||
co_return co_await _store.invoke_on( | ||
sub_shard, _smp_opts, [marker, sub{std::move(sub)}, m, f](store& s) { | ||
return s.set_mode(marker, sub, m, f).value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess our default result<>
configuration has a policy that throws on .value()
(rather than what I always assume to be undefined behavior if no value exists) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not default; but it does throw.
@@ -325,6 +331,9 @@ constexpr std::string_view to_string_view(seq_marker_key_type v) { | |||
case seq_marker_key_type::config: | |||
return "config"; | |||
break; | |||
case seq_marker_key_type::mode: | |||
return "mode"; | |||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break
unused here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks nice, a few questions
///\brief Get the mode for a subject, or fallback to global. | ||
result<mode> | ||
get_mode(const subject& sub, default_to_global fallback) const { | ||
auto sub_it = get_subject_iter(sub, include_deleted::yes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: Is include_deleted::yes
correct?
} else if (fallback) { | ||
return _mode; | ||
} | ||
return mode_not_found(sub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be subject_not_found
rather than mode_not_found
? Should mode_not_found
be returned if the subject exists and fallback is false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
subject_not_found
rather thanmode_not_found
? Shouldmode_not_found
be returned if the subject exists and fallback is false?
The mode configuration can exist without a subject. This is required so that a subject can be placed into import without the entire registry being in import.
result<void> check_mutable(force f) const { | ||
if (!_mutable && !f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Isn't the force flag for if there are already registered schemas and the mode is going into IMPORT
?
"type": "object", | ||
"properties": { | ||
"mode": { | ||
"type": "string" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: can this be an enum?
{ | ||
"name": "defaultToGlobal", | ||
"in": "query", | ||
"required": false, | ||
"type": "boolean" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: I don't see this in the API. Is this an undocumented option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. few questions mostly for my own benefit.
@@ -202,7 +202,7 @@ model::record_batch as_record_batch(Key key) { | |||
|
|||
SEASTAR_THREAD_TEST_CASE(test_consume_to_store_after_compaction) { | |||
pps::sharded_store s; | |||
s.start(ss::default_smp_service_group()).get(); | |||
s.start(pps::is_mutable::no, ss::default_smp_service_group()).get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why sometimes is_mutable::no
? branch coverage?
auto mode = co_await ss::coroutine::as_future( | ||
_store.get_subject_mode_written_at(sub)); | ||
if (!mode.failed()) { | ||
rb(mode.get()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it generally advisable to explicitly get_exception
(or discard or whatever) on the other side of the branch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it generally advisable to explicitly get_exception (or discard or whatever) on the other side of the branch here?
Yes, you need to eat the exception out of ready future to avoid abandoned exceptional future.
same below for conf
EDIT: for conf
i think I just noticed this in the PR that introduced that #17905 (review).
try { | ||
co_await seq._store.get_mode(sub, default_to_global::no); | ||
} catch (const exception&) { | ||
// subject config already blank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick:
// subject config already blank | |
// subject mode already blank |
auto mode = co_await ss::coroutine::as_future( | ||
_store.get_subject_mode_written_at(sub)); | ||
if (!mode.failed()) { | ||
rb(mode.get()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it generally advisable to explicitly get_exception (or discard or whatever) on the other side of the branch here?
Yes, you need to eat the exception out of ready future to avoid abandoned exceptional future.
same below for conf
EDIT: for conf
i think I just noticed this in the PR that introduced that #17905 (review).
Support
/mode
TODO:
is_mutable
a bit moreBackports Required
Release Notes
Features
/mode
endpoints