]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3435] add exception_handler to onNotification as well
authorAndrei Pavel <andrei@isc.org>
Thu, 20 Jun 2024 17:00:32 +0000 (20:00 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 20 Jun 2024 17:00:46 +0000 (20:00 +0300)
src/bin/netconf/netconf.cc
src/bin/netconf/netconf_messages.cc
src/bin/netconf/netconf_messages.h
src/bin/netconf/netconf_messages.mes

index 83dcaf7affb621d8db0ff7306d9a8a14a0baa749..331034485989c4567150326aae29e179cc23190d 100644 (file)
@@ -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>(subscription));
     } catch (exception const& ex) {
         ostringstream msg;
index e480b20e698e65aa8b4218820a537c87397e5766..a5b0f28bd6e1f078f69413f29aebce3491ae7d40 100644 (file)
@@ -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",
index 0568b32324f8558c6b81f1565f04b69c63165fe2..065406b317255002dcd7f9d7dfb887691efdde79 100644 (file)
@@ -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;
index ca68f70fb898c51a76c392293b8a8b7c30745748..ea601b3bc55319d6af11ed43ea311dbbab40b754 100644 (file)
@@ -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