Skip to content

Commit e897808

Browse files
committed
[#3435] add exception_handler to onNotification as well
1 parent cae551a commit e897808

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/bin/netconf/netconf.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,14 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
494494
timestamp);
495495
};
496496
try {
497-
Subscription subscription(running_sess_->onNotification(model, callback));
497+
auto exception_handler = [model](std::exception& ex) {
498+
LOG_ERROR(netconf_logger, NETCONF_NOTIFICATION_INTERNAL_ERROR)
499+
.arg(model)
500+
.arg(ex.what());
501+
};
502+
Subscription subscription(running_sess_->onNotification(model, callback, nullopt, nullopt,
503+
nullopt, SubscribeOptions::Default,
504+
exception_handler));
498505
subscriptions_.emplace(server, std::forward<Subscription>(subscription));
499506
} catch (exception const& ex) {
500507
ostringstream msg;

src/bin/netconf/netconf_messages.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR = "NETCONF_MODULE_MI
2323
extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN = "NETCONF_MODULE_MISSING_WARN";
2424
extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR = "NETCONF_MODULE_REVISION_ERR";
2525
extern const isc::log::MessageID NETCONF_MODULE_REVISION_WARN = "NETCONF_MODULE_REVISION_WARN";
26+
extern const isc::log::MessageID NETCONF_NOTIFICATION_INTERNAL_ERROR = "NETCONF_NOTIFICATION_INTERNAL_ERROR";
2627
extern const isc::log::MessageID NETCONF_NOTIFICATION_RECEIVED = "NETCONF_NOTIFICATION_RECEIVED";
2728
extern const isc::log::MessageID NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS = "NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS";
2829
extern const isc::log::MessageID NETCONF_RUN_EXIT = "NETCONF_RUN_EXIT";
@@ -65,6 +66,7 @@ const char* values[] = {
6566
"NETCONF_MODULE_MISSING_WARN", "Missing module %1 in sysrepo",
6667
"NETCONF_MODULE_REVISION_ERR", "Essential module %1 does NOT have the right revision: expected %2, got %3",
6768
"NETCONF_MODULE_REVISION_WARN", "Module %1 does NOT have the right revision: expected %2, got %3",
69+
"NETCONF_NOTIFICATION_INTERNAL_ERROR", "an internal error occurred while sending an event notification for module %1: %2",
6870
"NETCONF_NOTIFICATION_RECEIVED", "Received notification of type %1 for module %1: %2",
6971
"NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS", "subscribing to notifications for %1 server with %2 module failed: %3",
7072
"NETCONF_RUN_EXIT", "application is exiting the event loop",

src/bin/netconf/netconf_messages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR;
2424
extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN;
2525
extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR;
2626
extern const isc::log::MessageID NETCONF_MODULE_REVISION_WARN;
27+
extern const isc::log::MessageID NETCONF_NOTIFICATION_INTERNAL_ERROR;
2728
extern const isc::log::MessageID NETCONF_NOTIFICATION_RECEIVED;
2829
extern const isc::log::MessageID NETCONF_NOT_SUBSCRIBED_TO_NOTIFICATIONS;
2930
extern const isc::log::MessageID NETCONF_RUN_EXIT;

src/bin/netconf/netconf_messages.mes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ This warning message indicates that a module used by Kea is not at the
8080
right revision in the sysrepo repository. The name, expected and
8181
available revisions of the module are printed.
8282

83+
% NETCONF_NOTIFICATION_INTERNAL_ERROR an internal error occurred while sending an event notification for module %1: %2
84+
The error message indicates that kea-netconf got an error while sysrepo was sending an event notification.
85+
This error is not fatal and can be recovered from.
86+
The name of the module and the internal error message are printed.
87+
8388
% NETCONF_NOTIFICATION_RECEIVED Received notification of type %1 for module %1: %2
8489
This informational message logs any YANG notification that has been signaled
8590
by the server, sent to kea-netconf which then was forwarded to subscribed

0 commit comments

Comments
 (0)