Skip to content

common: modify md_config_obs_impl API#61394

Merged
ronen-fr merged 3 commits intoceph:mainfrom
ronen-fr:wip-rf-cacher-v2
Feb 2, 2025
Merged

common: modify md_config_obs_impl API#61394
ronen-fr merged 3 commits intoceph:mainfrom
ronen-fr:wip-rf-cacher-v2

Conversation

@ronen-fr
Copy link
Contributor

@ronen-fr ronen-fr commented Jan 15, 2025

Modify the md_config_cacher_t to implement the new get_tracked_conf_key() API.

Apart from resulting in a clearer code, this also solves the potential for a dangling
pointer issue that was present in the existing code.

This is a continuation of #61289. That PR was
enough to solve existing config-cacher bugs, and was created with backporting
in mind - but it was just one step on the road of improving the cacher. The current
PR is the next step.

@ronen-fr ronen-fr marked this pull request as ready for review January 16, 2025 12:39
class md_config_cacher_t : public md_config_obs_t {
ConfigProxy& conf;
const char* keys[2];
const std::string option_name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this is so cold part of the code that employing std::string seems purely beneficial.

* a leaner version of get_tracked_conf_keys() that returns a single key.
* If returns a valid string - get_tracked_conf_keys() will not be called.
*/
virtual std::optional<std::string> get_tracked_conf_key() const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a plan to deprecate / drop the old get_tracked_conf_keys()?
How much of work this would need?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, as most of the users register multiple keys.
I do want to change the signatures to 'const char * const *' - to better handle const strings as arguments.
But it might be a good idea to modify the multi-key interface altogether - to use strings and be copied directly into the strings of the config manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that's for the next PR...

Copy link
Member

Choose a reason for hiding this comment

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

I'm not really seeing a big benefit for this PR while it complicates the interface. It's not like we have a ton of config obs which only care about one option name?

I do agree something like std::array<std::string> const& would be preferable as a return type.

Copy link
Contributor Author

@ronen-fr ronen-fr Jan 25, 2025

Choose a reason for hiding this comment

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

@batrick

we have a ton of config obs which only care about one option name?

Yes - we will have (in the OSD), as we plan to move more 'change aware' configs to be wrapped in the single-key md_config_cacher_t (currently we have 11 of those, but that's just the beginning). The reason for this direction is that we've learned that the get<> interface for the configs is very slow.

std::arraystd::string const&

(I do not think we can use std::array, but std::vector is a valid choice).
I did not want to have to change all clients of the existing interface in this PR, and preferred to make that the next step. Not sure about the 'const&', though. I will have to play with that. If possible, I'd wish the actual texts to be moved-to during registration.

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 have modified the PR, discarding the one-key API. See comment below.

@rzarzynski rzarzynski requested a review from batrick January 16, 2025 16:47
@ronen-fr ronen-fr requested a review from rzarzynski January 23, 2025 09:17
@ronen-fr
Copy link
Contributor Author

@batrick - can you take a look? appreciate your input. Thanks.

* a leaner version of get_tracked_conf_keys() that returns a single key.
* If returns a valid string - get_tracked_conf_keys() will not be called.
*/
virtual std::optional<std::string> get_tracked_conf_key() const noexcept {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really seeing a big benefit for this PR while it complicates the interface. It's not like we have a ton of config obs which only care about one option name?

I do agree something like std::array<std::string> const& would be preferable as a return type.

@ronen-fr ronen-fr requested a review from batrick January 25, 2025 06:44
Adding a new version of the API used by the configuration
manager to find out what keys are handled by the specific
observer (and thus should be registered to be updated on
changes).

The new interface (get_tracked_keys()) returns a vector
of moveable strings.

Modify the ObserverMgr to use this new interface
when avaiable. The existing 'char**' based interface
is maintained for now, until all its clients are updated.

Signed-off-by: Ronen Friedman <[email protected]>
Modify the md_config_cacher_t to implement the new
get_tracked_keys() callback, instead of the deprecated
char* based get_tracked_conf_keys().

Signed-off-by: Ronen Friedman <[email protected]>
@ronen-fr
Copy link
Contributor Author

ronen-fr commented Jan 25, 2025

@batrick , @rzarzynski

Following the review comments, I have modified the PR as follows:

The Observer now has one new registration function:

  virtual std::vector<std::string> get_tracked_keys() const noexcept {
    ...
  }

this new one would be used for all registrations - including 'single key' ones.

The old const char** get_tracked_conf_keys() is maintained in
this PR as a deprecated legacy interface. I will create separate PRs
to change the dozens of clients that use that one, then remove it.

Note: the new interface returns a vector of strings that are moved
into the manager's main map.

static const char *KEYS[] = {"lockdep", NULL};
return KEYS;
std::vector<std::string> get_tracked_keys() const noexcept override {
return std::vector<std::string>{"lockdep"s};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not sure we really need to repeat the type; perhaps return {"lockdep"s}; would be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. Fixed.

modify some configuration object registrations
in common/ceph_context to use the updated
md_config_obs_t::get_tracked_keys() API

Signed-off-by: Ronen Friedman <[email protected]>
@ronen-fr ronen-fr dismissed batrick’s stale review January 30, 2025 08:04

Dismissing, as code changed per request, and re-reviewed by Radek

@ronen-fr
Copy link
Contributor Author

jenkins test make check

@ronen-fr
Copy link
Contributor Author

ronen-fr commented Feb 2, 2025

Merging based on my Teuthology tests, both as part of wip-rf-combined-30j, and as a separate branch.

@ronen-fr ronen-fr merged commit 519844b into ceph:main Feb 2, 2025
12 checks passed
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Feb 19, 2025
.. with get_tracked_keys().

This PR is but one of a set. Following
ceph#61394, all uses of
the deprecated interface will be updated, and that
old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
Matan-B pushed a commit to ceph/ceph-ci that referenced this pull request Feb 24, 2025
.. with get_tracked_keys().

This PR is but one of a set. Following
ceph/ceph#61394, all uses of
the deprecated interface will be updated, and that
old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
(cherry picked from commit f9e30c8)
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 2, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 2, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 2, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 3, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 3, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 5, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

As per the original code in this specific case: the
vector of keys is expected to be sorted.

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

As per the original code in this specific case: the
vector of keys is expected to be sorted.

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

As per the original code in this specific case: the
vector of keys is expected to be sorted.

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 9, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 10, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
ronen-fr added a commit to ronen-fr/ceph that referenced this pull request Mar 16, 2025
.. with get_tracked_keys().

Following ceph#61394,
all uses of the deprecated interface will be updated,
and that old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
harriscr pushed a commit to ceph/ceph-ci that referenced this pull request May 15, 2025
.. with get_tracked_keys().

This PR is but one of a set. Following
ceph/ceph#61394, all uses of
the deprecated interface will be updated, and that
old interface will be removed.

Signed-off-by: Ronen Friedman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants