diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 1fa82b965..10d0618f3 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -314,12 +314,13 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) } const std::string objtype = record["objtype"]; if (objtype == "network") { - // fprintf(stderr, "network save\n"); + fprintf(stderr, "CentralDB network save %s\n", record["id"].get().c_str()); const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); if (nwid) { nlohmann::json old; get(nwid, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { + fprintf(stderr, "posting network change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _commitQueue.post(std::pair(record, notifyListeners)); modified = true; @@ -331,12 +332,12 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) std::string memberId = record["id"]; const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); - // fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); + fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); if ((id) && (nwid)) { nlohmann::json network, old; get(nwid, network, id, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { - // fprintf(stderr, "commit queue post\n"); + fprintf(stderr, "posting member change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _commitQueue.post(std::pair(record, notifyListeners)); modified = true; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 2a7402a60..3e313dfe8 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -140,13 +140,22 @@ void PubSubNetworkListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (nc.has_old()) { + fprintf(stderr, "has old network config\n"); oldConfig = toJson(nc.old(), nc.change_source()); } if (nc.has_new_()) { + fprintf(stderr, "has new network config\n"); newConfig = toJson(nc.new_(), nc.change_source()); } + if (! nc.has_old() && ! nc.has_new_()) { + fprintf(stderr, "NetworkChange message has no old or new network config\n"); + span->SetAttribute("error", "NetworkChange message has no old or new network config"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); + return; + } + if (oldConfig.is_object() && newConfig.is_object()) { // network modification std::string nwid = oldConfig["id"].get(); @@ -186,6 +195,13 @@ void PubSubNetworkListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); return; } + catch (...) { + fprintf(stderr, "PubSubNetworkListener Unknown exception in PubSubNetworkListener\n"); + span->SetAttribute("error", "Unknown exception in PubSubNetworkListener"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Unknown exception"); + return; + } + fprintf(stderr, "PubSubNetworkListener onNotification complete\n"); } PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db) @@ -220,13 +236,22 @@ void PubSubMemberListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (mc.has_old()) { + fprintf(stderr, "has old member config\n"); oldConfig = toJson(mc.old(), mc.change_source()); } if (mc.has_new_()) { + fprintf(stderr, "has new member config\n"); newConfig = toJson(mc.new_(), mc.change_source()); } + if (! mc.has_old() && ! mc.has_new_()) { + fprintf(stderr, "MemberChange message has no old or new member config\n"); + span->SetAttribute("error", "MemberChange message has no old or new member config"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); + return; + } + if (oldConfig.is_object() && newConfig.is_object()) { // member modification std::string memberID = oldConfig["id"].get();