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

config: update bindings when properties are reset #16504

Merged
merged 6 commits into from
Feb 19, 2024

Conversation

ztlpn
Copy link
Contributor

@ztlpn ztlpn commented Feb 6, 2024

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

  • 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
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

Bug Fixes

  • Fix a bug that resulted in Redpanda ignoring until the next restart config values that were reset to their defaults.

dotnwat
dotnwat previously approved these changes Feb 6, 2024
Comment on lines -190 to -192
property<T>& operator()(T v) {
_value = std::move(v);
return *this;
Copy link
Member

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?

Copy link
Contributor Author

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.

Comment on lines 193 to 197
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;
}
Copy link
Member

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=.

Copy link
Contributor

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

// 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)

Copy link
Member

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.

Copy link
Contributor Author

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.

@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Feb 14, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da714-22dd-4c1a-8a14-8548725ac589:

"rptest.tests.cluster_config_test.ClusterConfigTest.test_rpk_import_sparse.all=False"

new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da73b-a118-4070-98b6-365a9eb0ef66:

"rptest.tests.cluster_config_test.ClusterConfigTest.test_rpk_import_sparse.all=True"

new failures in https://buildkite.com/redpanda/redpanda/builds/45036#018da73b-a115-4f6c-ae63-d398a3707264:

"rptest.tests.cluster_config_test.ClusterConfigTest.test_rpk_import_sparse.all=False"

@vbotbuildovich
Copy link
Collaborator

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.
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.
@ztlpn
Copy link
Contributor Author

ztlpn commented Feb 14, 2024

Ready for review!

Comment on lines +69 to +84

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);
}
}

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

@andijcr andijcr left a comment

Choose a reason for hiding this comment

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

lgtm

@mmaslankaprv mmaslankaprv merged commit f1f0b96 into redpanda-data:dev Feb 19, 2024
16 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.2.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.1.x

@vbotbuildovich
Copy link
Collaborator

Failed to create a backport PR to v23.2.x branch. I tried:

git remote add upstream https://github.com/redpanda-data/redpanda.git
git fetch --all
git checkout -b backport-pr-16504-v23.2.x-367 remotes/upstream/v23.2.x
git cherry-pick -x bde7db0e8185e0e9bd6e20783e065291f4c70525 30309ea5fb2c2521e6d5e42378ead610037d990c bb6e9b4ddc3f5c43cbd1c459143824f96f96a675 d58fe3db18ab7f13d531ffa11d1a836e8bb72db2 741158695070159595348cc766bfe51861d4166d 63eb446a94a5df3d7da64abd6e8f6e7bd26bb133

Workflow run logs.

@vbotbuildovich
Copy link
Collaborator

Failed to create a backport PR to v23.1.x branch. I tried:

git remote add upstream https://github.com/redpanda-data/redpanda.git
git fetch --all
git checkout -b backport-pr-16504-v23.1.x-331 remotes/upstream/v23.1.x
git cherry-pick -x bde7db0e8185e0e9bd6e20783e065291f4c70525 30309ea5fb2c2521e6d5e42378ead610037d990c bb6e9b4ddc3f5c43cbd1c459143824f96f96a675 d58fe3db18ab7f13d531ffa11d1a836e8bb72db2 741158695070159595348cc766bfe51861d4166d 63eb446a94a5df3d7da64abd6e8f6e7bd26bb133

Workflow run logs.

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