Skip to content

Commit cae551a

Browse files
committed
[#3435] add exception handling for module changes
1 parent e6c414e commit cae551a

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/bin/netconf/netconf.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,21 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) {
440440
Event event,
441441
uint32_t request_id) {
442442
NetconfAgentCallback agent(service_pair);
443-
return agent.module_change(session, subscription_id, module_name, sub_xpath, event, request_id);
443+
return agent.module_change(session, subscription_id, module_name, sub_xpath, event,
444+
request_id);
444445
};
445446
try {
446447
SubscribeOptions options(SubscribeOptions::Default);
447448
if (!configuration->getValidateChanges()) {
448449
options = options | SubscribeOptions::DoneOnly;
449450
}
451+
auto exception_handler = [model](std::exception& ex) {
452+
LOG_ERROR(netconf_logger, NETCONF_MODULE_CHANGE_INTERNAL_ERROR)
453+
.arg(model)
454+
.arg(ex.what());
455+
};
450456
Subscription subscription(
451-
running_sess_->onModuleChange(model, callback, nullopt, 0, options));
457+
running_sess_->onModuleChange(model, callback, nullopt, 0, options, exception_handler));
452458
subscriptions_.emplace(server, std::forward<Subscription>(subscription));
453459
} catch (exception const& ex) {
454460
ostringstream msg;
@@ -484,7 +490,8 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
484490
optional<DataNode> const notification_tree,
485491
NotificationTimeStamp const timestamp) {
486492
NetconfAgentCallback agent(service_pair);
487-
return agent.event_notif(session, subscription_id, notification_type, notification_tree, timestamp);
493+
return agent.event_notif(session, subscription_id, notification_type, notification_tree,
494+
timestamp);
488495
};
489496
try {
490497
Subscription subscription(running_sess_->onNotification(model, callback));

src/bin/netconf/netconf_messages.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern const isc::log::MessageID NETCONF_GET_CONFIG = "NETCONF_GET_CONFIG";
1818
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED = "NETCONF_GET_CONFIG_FAILED";
1919
extern const isc::log::MessageID NETCONF_GET_CONFIG_STARTED = "NETCONF_GET_CONFIG_STARTED";
2020
extern const isc::log::MessageID NETCONF_LOG_CHANGE_FAIL = "NETCONF_LOG_CHANGE_FAIL";
21+
extern const isc::log::MessageID NETCONF_MODULE_CHANGE_INTERNAL_ERROR = "NETCONF_MODULE_CHANGE_INTERNAL_ERROR";
2122
extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR = "NETCONF_MODULE_MISSING_ERR";
2223
extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN = "NETCONF_MODULE_MISSING_WARN";
2324
extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR = "NETCONF_MODULE_REVISION_ERR";
@@ -59,6 +60,7 @@ const char* values[] = {
5960
"NETCONF_GET_CONFIG_FAILED", "getting configuration from %1 server failed: %2",
6061
"NETCONF_GET_CONFIG_STARTED", "getting configuration from %1 server",
6162
"NETCONF_LOG_CHANGE_FAIL", "NETCONF configuration change logging failed: %1",
63+
"NETCONF_MODULE_CHANGE_INTERNAL_ERROR", "an internal error occurred while processing changes for module %1: %2",
6264
"NETCONF_MODULE_MISSING_ERR", "Missing essential module %1 in sysrepo",
6365
"NETCONF_MODULE_MISSING_WARN", "Missing module %1 in sysrepo",
6466
"NETCONF_MODULE_REVISION_ERR", "Essential module %1 does NOT have the right revision: expected %2, got %3",

src/bin/netconf/netconf_messages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern const isc::log::MessageID NETCONF_GET_CONFIG;
1919
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED;
2020
extern const isc::log::MessageID NETCONF_GET_CONFIG_STARTED;
2121
extern const isc::log::MessageID NETCONF_LOG_CHANGE_FAIL;
22+
extern const isc::log::MessageID NETCONF_MODULE_CHANGE_INTERNAL_ERROR;
2223
extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR;
2324
extern const isc::log::MessageID NETCONF_MODULE_MISSING_WARN;
2425
extern const isc::log::MessageID NETCONF_MODULE_REVISION_ERR;

src/bin/netconf/netconf_messages.mes

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2012-2023 Internet Systems Consortium, Inc. ("ISC")
1+
# Copyright (C) 2012-2024 Internet Systems Consortium, Inc. ("ISC")
22
#
33
# This Source Code Form is subject to the terms of the Mozilla Public
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -56,6 +56,11 @@ configuration from a Kea server.
5656
The warning message indicates that the configuration change logging
5757
encountered an unexpected condition. Details of it will be logged.
5858

59+
% NETCONF_MODULE_CHANGE_INTERNAL_ERROR an internal error occurred while processing changes for module %1: %2
60+
The error message indicates that kea-netconf got an error while sysrepo was processing modules changes.
61+
This usually follows a config validation failure, and can be recovered from.
62+
The name of the module and the internal error message are printed.
63+
5964
% NETCONF_MODULE_MISSING_ERR Missing essential module %1 in sysrepo
6065
This fatal error message indicates that a module required by Netconf
6166
configuration is not available in the sysrepo repository. The name of

0 commit comments

Comments
 (0)