From e7f897ed658d4ed199cce8f9f86ed6803b5e67f8 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 9 May 2020 02:33:43 +0300 Subject: [PATCH] Report hostname to etcd --- osd_cluster.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osd_cluster.cpp b/osd_cluster.cpp index 89d0bd71..7d02c0c7 100644 --- a/osd_cluster.cpp +++ b/osd_cluster.cpp @@ -122,12 +122,18 @@ void osd_t::parse_test_peer(std::string peer) json11::Json osd_t::get_osd_state() { + std::vector hostname; + hostname.resize(1024); + while (gethostname(hostname.data(), hostname.size()) < 0 && errno == ENAMETOOLONG) + hostname.resize(hostname.size()+1024); + hostname.resize(strnlen(hostname.data(), hostname.size())); json11::Json::object st; st["state"] = "up"; if (bind_address != "0.0.0.0") st["addresses"] = { bind_address }; else st["addresses"] = getifaddr_list(); + st["host"] = std::string(hostname.data(), hostname.size()); st["port"] = listening_port; st["primary_enabled"] = run_primary; st["blockstore_enabled"] = bs ? true : false;