From: Andrei Pavel Date: Thu, 20 Jun 2024 17:00:32 +0000 (+0300) Subject: [#3435] add exception_handler to onNotification as well X-Git-Tag: Kea-2.7.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8978082502b595edf3bb68098c1200840f66dc9;p=thirdparty%2Fkea.git [#3435] add exception_handler to onNotification as well --- diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index 83dcaf7aff..3310344859 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -494,7 +494,14 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) { timestamp); }; try { - Subscription subscription(running_sess_->onNotification(model, callback)); + auto exception_handler = [model](std::exception& ex) { + LOG_ERROR(netconf_logger, NETCONF_NOTIFICATION_INTERNAL_ERROR) + .arg(model) + .arg(ex.what()); + }; + Subscription subscription(running_sess_->onNotification(model, callback, nullopt, nullopt, + nullopt, SubscribeOptions::Default, + exception_handler)); subscriptions_.emplace(server, std::forward(subscription)); } catch (exception const& ex) { ostringstream msg; diff --git a/src/bin/netconf/netconf_messages.cc b/src/bin/netconf/netconf_messages.cc index e480b20e69..a5b0f28bd6 100644 --- a/src/bin/netconf/netconf_messages.cc +++ b/src/bin/netconf/netconf_messages.cc @@ -23,6 +23,7 @@ extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR = "NETCONF_MODULE_MI extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN = "NETCONF_MODULE_MISSING_WARN"; extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR = "NETCONF_MODULE_REVISION_ERR"; extern const isc::log::MessageID NETCONF_MODULE_REVISION_WARN = "NETCONF_MODULE_REVISION_WARN"; +extern const isc::log::MessageID NETCONF_NOTIFICATION_INTERNAL_ERROR = "NETCONF_NOTIFICATION_INTERNAL_ERROR"; extern const isc::log::MessageID NETCONF_NOTIFICATION_RECEIVED = "NETCONF_NOTIFICATION_RECEIVED"; extern const isc::log::MessageID NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS = "NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS"; extern const isc::log::MessageID NETCONF_RUN_EXIT = "NETCONF_RUN_EXIT"; @@ -65,6 +66,7 @@ const char* values[] = { "NETCONF_MODULE_MISSING_WARN", "Missing module %1 in sysrepo", "NETCONF_MODULE_REVISION_ERR", "Essential module %1 does NOT have the right revision: expected %2, got %3", "NETCONF_MODULE_REVISION_WARN", "Module %1 does NOT have the right revision: expected %2, got %3", + "NETCONF_NOTIFICATION_INTERNAL_ERROR", "an internal error occurred while sending an event notification for module %1: %2", "NETCONF_NOTIFICATION_RECEIVED", "Received notification of type %1 for module %1: %2", "NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS", "subscribing to notifications for %1 server with %2 module failed: %3", "NETCONF_RUN_EXIT", "application is exiting the event loop", diff --git a/src/bin/netconf/netconf_messages.h b/src/bin/netconf/netconf_messages.h index 0568b32324..065406b317 100644 --- a/src/bin/netconf/netconf_messages.h +++ b/src/bin/netconf/netconf_messages.h @@ -24,6 +24,7 @@ extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR; extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN; extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR; extern const isc::log::MessageID NETCONF_MODULE_REVISION_WARN; +extern const isc::log::MessageID NETCONF_NOTIFICATION_INTERNAL_ERROR; extern const isc::log::MessageID NETCONF_NOTIFICATION_RECEIVED; extern const isc::log::MessageID NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS; extern const isc::log::MessageID NETCONF_RUN_EXIT; diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes index ca68f70fb8..ea601b3bc5 100644 --- a/src/bin/netconf/netconf_messages.mes +++ b/src/bin/netconf/netconf_messages.mes @@ -80,6 +80,11 @@ This warning message indicates that a module used by Kea is not at the right revision in the sysrepo repository. The name, expected and available revisions of the module are printed. +% NETCONF_NOTIFICATION_INTERNAL_ERROR an internal error occurred while sending an event notification for module %1: %2 +The error message indicates that kea-netconf got an error while sysrepo was sending an event notification. +This error is not fatal and can be recovered from. +The name of the module and the internal error message are printed. + % NETCONF_NOTIFICATION_RECEIVED Received notification of type %1 for module %1: %2 This informational message logs any YANG notification that has been signaled by the server, sent to kea-netconf which then was forwarded to subscribed