Skip to content

Commit 7aa844e

Browse files
authored
Merge pull request ceph#62074 from ronen-fr/wip-rf-more4-keys
mon,mgr,auth,client: replace obsolete get_tracked_conf_keys() Reviewed-by: Matan Breizman <[email protected]> Reviewed-by: Radoslaw Zarzynski <[email protected]>
2 parents a6a6c83 + 2c03fc6 commit 7aa844e

File tree

16 files changed

+113
-135
lines changed

16 files changed

+113
-135
lines changed

src/auth/AuthRegistry.cc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define dout_prefix *_dout << "AuthRegistry(" << this << ") "
1818

1919
using std::string;
20+
using namespace std::literals;
2021

2122
AuthRegistry::AuthRegistry(CephContext *cct)
2223
: cct(cct)
@@ -32,23 +33,21 @@ AuthRegistry::~AuthRegistry()
3233
}
3334
}
3435

35-
const char** AuthRegistry::get_tracked_conf_keys() const
36+
std::vector<std::string> AuthRegistry::get_tracked_keys() const noexcept
3637
{
37-
static const char *keys[] = {
38-
"auth_supported",
39-
"auth_client_required",
40-
"auth_cluster_required",
41-
"auth_service_required",
42-
"ms_mon_cluster_mode",
43-
"ms_mon_service_mode",
44-
"ms_mon_client_mode",
45-
"ms_cluster_mode",
46-
"ms_service_mode",
47-
"ms_client_mode",
48-
"keyring",
49-
NULL
38+
return {
39+
"auth_supported"s,
40+
"auth_client_required"s,
41+
"auth_cluster_required"s,
42+
"auth_service_required"s,
43+
"ms_mon_cluster_mode"s,
44+
"ms_mon_service_mode"s,
45+
"ms_mon_client_mode"s,
46+
"ms_cluster_mode"s,
47+
"ms_service_mode"s,
48+
"ms_client_mode"s,
49+
"keyring"s
5050
};
51-
return keys;
5251
}
5352

5453
void AuthRegistry::handle_conf_change(

src/auth/AuthRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class AuthRegistry : public md_config_obs_t {
7070

7171
AuthAuthorizeHandler *get_handler(int peer_type, int method);
7272

73-
const char** get_tracked_conf_keys() const override;
73+
std::vector<std::string> get_tracked_keys() const noexcept override;
7474
void handle_conf_change(const ConfigProxy& conf,
7575
const std::set<std::string>& changed) override;
7676

src/client/Client.cc

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ using std::vector;
172172
using namespace std::literals;
173173

174174
using namespace TOPNSPC::common;
175+
using namespace std::literals;
175176

176177
namespace bs = boost::system;
177178
namespace ca = ceph::async;
@@ -17332,38 +17333,26 @@ void Client::set_cap_epoch_barrier(epoch_t e)
1733217333
cap_epoch_barrier = e;
1733317334
}
1733417335

17335-
const char** Client::get_tracked_conf_keys() const
17336-
{
17337-
#define KEYS \
17338-
"client_acl_type", \
17339-
"client_cache_mid", \
17340-
"client_cache_size", \
17341-
"client_caps_release_delay", \
17342-
"client_deleg_break_on_open", \
17343-
"client_deleg_timeout", \
17344-
"client_mount_timeout", \
17345-
"client_oc_max_dirty", \
17346-
"client_oc_max_dirty_age", \
17347-
"client_oc_max_objects", \
17348-
"client_oc_size", \
17349-
"client_oc_target_dirty", \
17350-
"client_permissions", \
17336+
std::vector<std::string> Client::get_tracked_keys() const noexcept
17337+
{
17338+
static constexpr auto as_sv = std::to_array<std::string_view>({
17339+
"client_acl_type",
17340+
"client_cache_mid",
17341+
"client_cache_size",
17342+
"client_caps_release_delay",
17343+
"client_deleg_break_on_open",
17344+
"client_deleg_timeout",
17345+
"client_mount_timeout",
17346+
"client_oc_max_dirty",
17347+
"client_oc_max_dirty_age",
17348+
"client_oc_max_objects",
17349+
"client_oc_size",
17350+
"client_oc_target_dirty",
17351+
"client_permissions",
1735117352
"fuse_default_permissions"
17352-
17353-
constexpr bool is_sorted = [] () constexpr {
17354-
constexpr auto arr = std::to_array<std::string_view>({KEYS});
17355-
for (unsigned long i = 0; i < arr.size()-1; ++i) {
17356-
if (arr[i] > arr[i+1]) {
17357-
return false;
17358-
}
17359-
}
17360-
return true;
17361-
}();
17362-
static_assert(is_sorted, "keys are not sorted!");
17363-
17364-
static char const* keys[] = {KEYS, nullptr};
17365-
17366-
return keys;
17353+
});
17354+
static_assert(std::is_sorted(begin(as_sv), end(as_sv)));
17355+
return {begin(as_sv), end(as_sv)};
1736717356
}
1736817357

1736917358
void Client::handle_conf_change(const ConfigProxy& conf,

src/client/Client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ class Client : public Dispatcher, public md_config_obs_t {
696696
int ll_register_callbacks2(struct ceph_client_callback_args *args);
697697
std::pair<int, bool> test_dentry_handling(bool can_invalidate);
698698

699-
const char** get_tracked_conf_keys() const override;
699+
std::vector<std::string> get_tracked_keys() const noexcept override;
700700
void handle_conf_change(const ConfigProxy& conf,
701701
const std::set <std::string> &changed) override;
702702
uint32_t get_deleg_timeout() { return deleg_timeout; }

src/mgr/DaemonServer.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define dout_prefix *_dout << "mgr.server " << __func__ << " "
6363

6464
using namespace TOPNSPC::common;
65+
using namespace std::literals;
6566

6667
using std::list;
6768
using std::ostream;
@@ -3182,15 +3183,12 @@ void DaemonServer::got_mgr_map()
31823183
daemon_state.cull("mgr", have);
31833184
}
31843185

3185-
const char** DaemonServer::get_tracked_conf_keys() const
3186+
std::vector<std::string> DaemonServer::get_tracked_keys() const noexcept
31863187
{
3187-
static const char *KEYS[] = {
3188-
"mgr_stats_threshold",
3189-
"mgr_stats_period",
3190-
nullptr
3188+
return {
3189+
"mgr_stats_threshold"s,
3190+
"mgr_stats_period"s
31913191
};
3192-
3193-
return KEYS;
31943192
}
31953193

31963194
void DaemonServer::handle_conf_change(const ConfigProxy& conf,

src/mgr/DaemonServer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ class DaemonServer : public Dispatcher, public md_config_obs_t
309309
void reregister_mds_perf_queries();
310310
int get_mds_perf_counters(MDSPerfCollector *collector);
311311

312-
virtual const char** get_tracked_conf_keys() const override;
313-
virtual void handle_conf_change(const ConfigProxy& conf,
312+
std::vector<std::string> get_tracked_keys() const noexcept override;
313+
void handle_conf_change(const ConfigProxy& conf,
314314
const std::set <std::string> &changed) override;
315315

316316
void schedule_tick(double delay_sec);

src/mgr/MgrStandby.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
using std::map;
4141
using std::string;
4242
using std::vector;
43+
using namespace std::literals;
4344

4445
MgrStandby::MgrStandby(int argc, const char **argv) :
4546
Dispatcher(g_ceph_context),
@@ -68,23 +69,21 @@ MgrStandby::MgrStandby(int argc, const char **argv) :
6869

6970
MgrStandby::~MgrStandby() = default;
7071

71-
const char** MgrStandby::get_tracked_conf_keys() const
72+
std::vector<std::string> MgrStandby::get_tracked_keys() const noexcept
7273
{
73-
static const char* KEYS[] = {
74+
return {
7475
// clog & admin clog
75-
"clog_to_monitors",
76-
"clog_to_syslog",
77-
"clog_to_syslog_facility",
78-
"clog_to_syslog_level",
79-
"clog_to_graylog",
80-
"clog_to_graylog_host",
81-
"clog_to_graylog_port",
82-
"mgr_standby_modules",
83-
"host",
84-
"fsid",
85-
NULL
76+
"clog_to_monitors"s,
77+
"clog_to_syslog"s,
78+
"clog_to_syslog_facility"s,
79+
"clog_to_syslog_level"s,
80+
"clog_to_graylog"s,
81+
"clog_to_graylog_host"s,
82+
"clog_to_graylog_port"s,
83+
"mgr_standby_modules"s,
84+
"host"s,
85+
"fsid"s
8686
};
87-
return KEYS;
8887
}
8988

9089
void MgrStandby::handle_conf_change(

src/mgr/MgrStandby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MgrStandby : public Dispatcher,
3434
public md_config_obs_t {
3535
public:
3636
// config observer bits
37-
const char** get_tracked_conf_keys() const override;
37+
std::vector<std::string> get_tracked_keys() const noexcept override;
3838
void handle_conf_change(const ConfigProxy& conf,
3939
const std::set <std::string> &changed) override;
4040

src/mon/LogMonitor.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#define dout_subsys ceph_subsys_mon
6767

6868
using namespace TOPNSPC::common;
69+
using namespace std::literals;
6970

7071
using std::cerr;
7172
using std::cout;
@@ -1270,6 +1271,19 @@ void LogMonitor::update_log_channels()
12701271
log_external_close_fds();
12711272
}
12721273

1274+
std::vector<std::string> LogMonitor::get_tracked_keys() const noexcept
1275+
{
1276+
return {
1277+
"mon_cluster_log_to_syslog"s,
1278+
"mon_cluster_log_to_syslog_facility"s,
1279+
"mon_cluster_log_file"s,
1280+
"mon_cluster_log_level"s,
1281+
"mon_cluster_log_to_graylog"s,
1282+
"mon_cluster_log_to_graylog_host"s,
1283+
"mon_cluster_log_to_graylog_port"s,
1284+
"mon_cluster_log_to_journald"s,
1285+
"mon_cluster_log_to_file"s
1286+
};}
12731287

12741288
void LogMonitor::handle_conf_change(const ConfigProxy& conf,
12751289
const std::set<std::string> &changed)

src/mon/LogMonitor.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,7 @@ class LogMonitor : public PaxosService,
182182
g_conf().remove_observer(this);
183183
}
184184

185-
const char **get_tracked_conf_keys() const override {
186-
static const char* KEYS[] = {
187-
"mon_cluster_log_to_syslog",
188-
"mon_cluster_log_to_syslog_facility",
189-
"mon_cluster_log_file",
190-
"mon_cluster_log_level",
191-
"mon_cluster_log_to_graylog",
192-
"mon_cluster_log_to_graylog_host",
193-
"mon_cluster_log_to_graylog_port",
194-
"mon_cluster_log_to_journald",
195-
NULL
196-
};
197-
return KEYS;
198-
}
185+
std::vector<std::string> get_tracked_keys() const noexcept override;
199186
void handle_conf_change(const ConfigProxy& conf,
200187
const std::set<std::string> &changed) override;
201188
};

0 commit comments

Comments
 (0)