-
Notifications
You must be signed in to change notification settings - Fork 553
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
config: update bindings when properties are reset #16504
config: update bindings when properties are reset #16504
Conversation
property<T>& operator()(T v) { | ||
_value = std::move(v); | ||
return *this; |
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.
what happened to this operator?
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 had a choice of using update_value there as well, but chose to delete it because, well, using operator() to set a value is a bit confusing IMO. Turned out it was still being used in a test. Fixed that and moved the change to a separate config.
base_property& operator=(const base_property& pr) override { | ||
_value = dynamic_cast<const property<T>&>(pr)._value; | ||
auto v = dynamic_cast<const property<T>&>(pr)._value; | ||
update_value(std::move(v)); | ||
return *this; | ||
} |
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.
good catch. presumably this is fine, but it feels really error prone to be able to use operator= to assign a value like this, in which case, would only be changed on the current core and not all cores. i wonder how many users there are of this operator=.
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 used in patch_cluster_config (and hopefully nowhere else) to create a copy of the configuration to validate incoming upserts
redpanda/src/v/redpanda/admin/server.cc
Lines 1702 to 1707 in 0afd0bd
// Populate the temporary config object with existing values | |
config::shard_local_cfg().for_each( | |
[&cfg](const config::base_property& p) { | |
auto& tmp_p = cfg.get(p.name()); | |
tmp_p = p; | |
}); |
given this use, update_value isn't strictly needed here (the bindings are empty in that function)
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.
got it, thanks. then it seems ok. the operator= is still weird but we can address it in the future if/when we redesign the config system.
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.
Yeah, using operator= here is a bit confusing as well. I chose to use update_value here as well so that all value-setting methods use it, but ultimately IMO we should use something more explicit here.
af44064
to
ebe7a95
Compare
3f33c72
to
337e935
Compare
new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da714-22dd-4c1a-8a14-8548725ac589:
new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da73b-a118-4070-98b6-365a9eb0ef66:
new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da73b-a115-4f6c-ae63-d398a3707264:
|
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/45036#018da73b-a115-4f6c-ae63-d398a3707264 |
Previously, the max_connections_per_ip watch callback assumed that if there are overrides present, the main per-ip limit is there as well.
Remove an old way of setting the property value that was only used in tests.
337e935
to
7f4da21
Compare
Previously, if one of the binding watch callbacks threw an exception, the main property value didn't get updated, resulting in an inconsistency.
Previously we just set the value without notifying bindings. This lead to ignoring property value updates when the property was reset to its default value as a result of a patch_cluster_config request with non-empty "remove" section.
7f4da21
to
63eb446
Compare
Ready for review! |
|
||
if (_cfg.max_connections_overrides().empty()) { | ||
ip_home.clear(); | ||
} else { | ||
// Remove everything except the overrides. | ||
std::vector<inet_address_key> to_delete; | ||
for (const auto& i : ip_home) { | ||
if (!overrides.contains(i.first)) { | ||
to_delete.push_back(i.first); | ||
} | ||
} | ||
for (const auto& k : to_delete) { | ||
ip_home.erase(k); | ||
} | ||
} | ||
|
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.
was this the watcher throwing the exception?
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.
nit: seems like you could use directly
std::erase_if
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
/backport v23.3.x |
/backport v23.2.x |
/backport v23.1.x |
Failed to create a backport PR to v23.2.x branch. I tried:
|
Failed to create a backport PR to v23.1.x branch. I tried:
|
Previously we just set the value without notifying bindings. This led to ignoring property value updates when the property was reset to its default value as a result of a patch_cluster_config request with non-empty "remove" section.
Backports Required
Release Notes
Bug Fixes