1313#include " messages/MMgrOpen.h"
1414#include " messages/MMgrReport.h"
1515
16- namespace {
17- seastar::logger& logger ()
18- {
19- return crimson::get_logger (ceph_subsys_mgrc);
20- }
21- }
16+ SET_SUBSYS (mgrc);
2217
2318using crimson::common::local_conf;
2419
@@ -38,15 +33,19 @@ Client::Client(crimson::net::Messenger& msgr,
3833
3934seastar::future<> Client::start ()
4035{
36+ LOG_PREFIX (Client::start);
37+ DEBUGDPP (" " , *this );
4138 return seastar::now ();
4239}
4340
4441seastar::future<> Client::stop ()
4542{
46- logger ().info (" {}" , __func__);
43+ LOG_PREFIX (Client::stop);
44+ DEBUGDPP (" " , *this );
4745 report_timer.cancel ();
4846 auto fut = gates.close_all ();
4947 if (conn) {
48+ DEBUGDPP (" marking down" , *this );
5049 conn->mark_down ();
5150 }
5251 return fut;
@@ -55,8 +54,12 @@ seastar::future<> Client::stop()
5554std::optional<seastar::future<>>
5655Client::ms_dispatch (crimson::net::ConnectionRef conn, MessageRef m)
5756{
57+ LOG_PREFIX (Client::ms_dispatch);
58+ DEBUGDPP (" {}" , *this , *m);
5859 bool dispatched = true ;
59- gates.dispatch_in_background (__func__, *this , [this , conn, &m, &dispatched] {
60+ gates.dispatch_in_background (__func__, *this ,
61+ [this , conn, &m, &dispatched, FNAME] {
62+ DEBUGDPP (" dispatching in background {}" , *this , *m);
6063 switch (m->get_type ()) {
6164 case MSG_MGR_MAP:
6265 return handle_mgr_map (conn, boost::static_pointer_cast<MMgrMap>(m));
@@ -74,24 +77,33 @@ void Client::ms_handle_connect(
7477 crimson::net::ConnectionRef c,
7578 seastar::shard_id prv_shard)
7679{
80+ LOG_PREFIX (Client::ms_handle_connect);
81+ DEBUGDPP (" prev_shard: {}" , *this , prv_shard);
7782 ceph_assert_always (prv_shard == seastar::this_shard_id ());
78- gates.dispatch_in_background (__func__, *this , [this , c] {
83+ gates.dispatch_in_background (__func__, *this ,
84+ [this , c, FNAME] {
7985 if (conn == c) {
86+ DEBUGDPP (" dispatching in background" , *this );
8087 // ask for the mgrconfigure message
8188 auto m = crimson::make_message<MMgrOpen>();
8289 m->daemon_name = local_conf ()->name .get_id ();
8390 local_conf ().get_config_bl (0 , &m->config_bl , &last_config_bl_version);
8491 local_conf ().get_defaults_bl (&m->config_defaults_bl );
8592 return conn->send (std::move (m));
8693 } else {
94+ DEBUGDPP (" connection changed" , *this );
8795 return seastar::now ();
8896 }
8997 });
9098}
9199
92100void Client::ms_handle_reset (crimson::net::ConnectionRef c, bool /* is_replace */ )
93101{
94- gates.dispatch_in_background (__func__, *this , [this , c] {
102+ LOG_PREFIX (Client::ms_handle_reset);
103+ DEBUGDPP (" " , *this );
104+ gates.dispatch_in_background (__func__, *this ,
105+ [this , c, FNAME] {
106+ DEBUGDPP (" dispatching in background" , *this );
95107 if (conn == c) {
96108 report_timer.cancel ();
97109 return reconnect ();
@@ -103,33 +115,40 @@ void Client::ms_handle_reset(crimson::net::ConnectionRef c, bool /* is_replace *
103115
104116seastar::future<> Client::reconnect ()
105117{
118+ LOG_PREFIX (Client::reconnect);
119+ DEBUGDPP (" " , *this );
106120 if (conn) {
121+ DEBUGDPP (" marking down" , *this );
107122 conn->mark_down ();
108123 conn = {};
109124 }
110125 if (!mgrmap.get_available ()) {
111- logger (). warn ( " No active mgr available yet" );
126+ WARNDPP ( " No active mgr available yet" , * this );
112127 return seastar::now ();
113128 }
114129 auto retry_interval = std::chrono::duration<double >(
115130 local_conf ().get_val <double >(" mgr_connect_retry_interval" ));
116131 auto a_while = std::chrono::duration_cast<seastar::steady_clock_type::duration>(
117132 retry_interval);
118- return seastar::sleep (a_while).then ([this ] {
133+ DEBUGDPP (" reconnecting in {} seconds" , *this , retry_interval);
134+ return seastar::sleep (a_while).then ([this , FNAME] {
119135 auto peer = mgrmap.get_active_addrs ().pick_addr (msgr.get_myaddr ().get_type ());
120136 if (peer == entity_addr_t {}) {
121137 // crimson msgr only uses the first bound addr
122- logger (). error (" mgr.{} does not have an addr compatible with me" ,
123- mgrmap.get_active_name ());
138+ ERRORDPP (" mgr.{} does not have an addr compatible with me" ,
139+ * this , mgrmap.get_active_name ());
124140 return ;
125141 }
126142 conn = msgr.connect (peer, CEPH_ENTITY_TYPE_MGR);
143+ DEBUGDPP (" reconnected successfully" , *this );
127144 });
128145}
129146
130147seastar::future<> Client::handle_mgr_map (crimson::net::ConnectionRef,
131148 Ref<MMgrMap> m)
132149{
150+ LOG_PREFIX (Client::handle_mgr_map);
151+ DEBUGDPP (" " , *this );
133152 mgrmap = m->get_map ();
134153 if (!conn) {
135154 return reconnect ();
@@ -144,7 +163,8 @@ seastar::future<> Client::handle_mgr_map(crimson::net::ConnectionRef,
144163seastar::future<> Client::handle_mgr_conf (crimson::net::ConnectionRef,
145164 Ref<MMgrConfigure> m)
146165{
147- logger ().info (" {} {}" , __func__, *m);
166+ LOG_PREFIX (Client::handle_mgr_conf);
167+ DEBUGDPP (" {}" , *this , *m);
148168
149169 auto report_period = std::chrono::seconds{m->stats_period };
150170 if (report_period.count ()) {
@@ -165,16 +185,19 @@ seastar::future<> Client::handle_mgr_conf(crimson::net::ConnectionRef,
165185
166186void Client::report ()
167187{
188+ LOG_PREFIX (Client::report);
189+ DEBUGDPP (" " , *this );
168190 _send_report ();
169- gates.dispatch_in_background (__func__, *this , [this ] {
191+ gates.dispatch_in_background (__func__, *this , [this , FNAME] {
192+ DEBUGDPP (" dispatching in background" , *this );
170193 if (!conn) {
171- logger (). warn ( " report: no conn available; report skipped" );
194+ WARNDPP ( " no conn available; report skipped" , * this );
172195 return seastar::now ();
173196 }
174197 return with_stats.get_stats (
175- ).then ([this ](auto &&pg_stats) {
198+ ).then ([this , FNAME ](auto &&pg_stats) {
176199 if (!conn) {
177- logger (). warn ( " report: no conn available; before sending stats, report skipped" );
200+ WARNDPP ( " no conn available; before sending stats, report skipped" , * this );
178201 return seastar::now ();
179202 }
180203 return conn->send (std::move (pg_stats));
@@ -189,9 +212,12 @@ void Client::update_daemon_health(std::vector<DaemonHealthMetric>&& metrics)
189212
190213void Client::_send_report ()
191214{
192- gates.dispatch_in_background (__func__, *this , [this ] {
215+ LOG_PREFIX (Client::_send_report);
216+ DEBUGDPP (" " , *this );
217+ gates.dispatch_in_background (__func__, *this , [this , FNAME] {
218+ DEBUGDPP (" dispatching in background" , *this );
193219 if (!conn) {
194- logger (). warn ( " cannot send report; no conn available" );
220+ WARNDPP ( " cannot send report; no conn available" , * this );
195221 return seastar::now ();
196222 }
197223 auto report = make_message<MMgrReport>();
0 commit comments