.. confval:: mon_memory_autotune
.. confval:: enable_availability_tracking
+NVMe-oF Monitor Client
+=====================
+
+.. confval:: nvmeof_mon_client_disconnect_panic
+.. confval:: nvmeof_mon_client_connect_panic
+.. confval:: nvmeof_mon_client_tick_period
+
.. _Paxos: https://en.wikipedia.org/wiki/Paxos_(computer_science)
.. _Monitor Keyrings: ../../../dev/mon-bootstrap#secret-keys
.. _Ceph configuration file: ../ceph-conf/#monitors
gwmap_epoch(0),
last_map_time(std::chrono::steady_clock::now()),
reset_timestamp(std::chrono::steady_clock::now()),
+ start_time(last_map_time),
monc{g_ceph_context, poolctx},
client_messenger(Messenger::create(g_ceph_context, "async", entity_name_t::CLIENT(-1), "client", getpid())),
objecter{g_ceph_context, client_messenger.get(), &monc, poolctx},
}
}
+void NVMeofGwMonitorClient::connect_panic()
+{
+ // Return immediately if the gateway was assigned group ID by the monitor
+ if (set_group_id) {
+ return;
+ }
+ // If the gateway has not been assigned a group ID, panic after timeout
+ auto connect_panic_duration = g_conf().get_val<std::chrono::seconds>("nvmeof_mon_client_connect_panic").count();
+ auto now = std::chrono::steady_clock::now();
+ auto elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>(now - start_time).count();
+ if (elapsed_seconds > connect_panic_duration) {
+ dout(4) << "Triggering a panic: did not receive initial map from monitor, elapsed " << elapsed_seconds << ", configured connect panic duration " << connect_panic_duration << " seconds." << dendl;
+ throw std::runtime_error("Did not receive initial map from monitor (connect panic).");
+ }
+}
+
void NVMeofGwMonitorClient::tick()
{
dout(10) << dendl;
+ connect_panic();
disconnect_panic();
send_beacon();
first_beacon = false;
dout(10) << "Can not find new gw state" << dendl;
return;
}
- bool set_group_id = false;
+ ceph_assert(!set_group_id);
while (!set_group_id) {
NVMeofGwMonitorGroupClient monitor_group_client(
grpc::CreateChannel(monitor_address, gw_creds()));
last_map_time; // used to panic on disconnect
std::chrono::time_point<std::chrono::steady_clock>
reset_timestamp; // used to bypass some validations
+ std::chrono::time_point<std::chrono::steady_clock>
+ start_time; // used to panic on connect
bool first_beacon = true;
+ bool set_group_id = false;
+
// init gw ssl opts
void init_gw_ssl_opts();
void disconnect_panic();
void handle_nvmeof_gw_map(ceph::ref_t<MNVMeofGwMap> m);
+
+ void connect_panic();
};
#endif