2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#3435] add exception handling for module changes

This commit is contained in:
Andrei Pavel 2024-05-27 17:47:42 +03:00
parent e6c414e9af
commit cae551ae9b
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
4 changed files with 19 additions and 4 deletions

View File

@ -440,15 +440,21 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) {
Event event,
uint32_t request_id) {
NetconfAgentCallback agent(service_pair);
return agent.module_change(session, subscription_id, module_name, sub_xpath, event, request_id);
return agent.module_change(session, subscription_id, module_name, sub_xpath, event,
request_id);
};
try {
SubscribeOptions options(SubscribeOptions::Default);
if (!configuration->getValidateChanges()) {
options = options | SubscribeOptions::DoneOnly;
}
auto exception_handler = [model](std::exception& ex) {
LOG_ERROR(netconf_logger, NETCONF_MODULE_CHANGE_INTERNAL_ERROR)
.arg(model)
.arg(ex.what());
};
Subscription subscription(
running_sess_->onModuleChange(model, callback, nullopt, 0, options));
running_sess_->onModuleChange(model, callback, nullopt, 0, options, exception_handler));
subscriptions_.emplace(server, std::forward<Subscription>(subscription));
} catch (exception const& ex) {
ostringstream msg;
@ -484,7 +490,8 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
optional<DataNode> const notification_tree,
NotificationTimeStamp const timestamp) {
NetconfAgentCallback agent(service_pair);
return agent.event_notif(session, subscription_id, notification_type, notification_tree, timestamp);
return agent.event_notif(session, subscription_id, notification_type, notification_tree,
timestamp);
};
try {
Subscription subscription(running_sess_->onNotification(model, callback));

View File

@ -18,6 +18,7 @@ extern const isc::log::MessageID NETCONF_GET_CONFIG = "NETCONF_GET_CONFIG";
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED = "NETCONF_GET_CONFIG_FAILED";
extern const isc::log::MessageID NETCONF_GET_CONFIG_STARTED = "NETCONF_GET_CONFIG_STARTED";
extern const isc::log::MessageID NETCONF_LOG_CHANGE_FAIL = "NETCONF_LOG_CHANGE_FAIL";
extern const isc::log::MessageID NETCONF_MODULE_CHANGE_INTERNAL_ERROR = "NETCONF_MODULE_CHANGE_INTERNAL_ERROR";
extern const isc::log::MessageID NETCONF_MODULE_MISSING_ERR = "NETCONF_MODULE_MISSING_ERR";
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";
@ -59,6 +60,7 @@ const char* values[] = {
"NETCONF_GET_CONFIG_FAILED", "getting configuration from %1 server failed: %2",
"NETCONF_GET_CONFIG_STARTED", "getting configuration from %1 server",
"NETCONF_LOG_CHANGE_FAIL", "NETCONF configuration change logging failed: %1",
"NETCONF_MODULE_CHANGE_INTERNAL_ERROR", "an internal error occurred while processing changes for module %1: %2",
"NETCONF_MODULE_MISSING_ERR", "Missing essential module %1 in sysrepo",
"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",

View File

@ -19,6 +19,7 @@ extern const isc::log::MessageID NETCONF_GET_CONFIG;
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED;
extern const isc::log::MessageID NETCONF_GET_CONFIG_STARTED;
extern const isc::log::MessageID NETCONF_LOG_CHANGE_FAIL;
extern const isc::log::MessageID NETCONF_MODULE_CHANGE_INTERNAL_ERROR;
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;

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2023 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2012-2024 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
@ -56,6 +56,11 @@ configuration from a Kea server.
The warning message indicates that the configuration change logging
encountered an unexpected condition. Details of it will be logged.
% NETCONF_MODULE_CHANGE_INTERNAL_ERROR an internal error occurred while processing changes for module %1: %2
The error message indicates that kea-netconf got an error while sysrepo was processing modules changes.
This usually follows a config validation failure, and can be recovered from.
The name of the module and the internal error message are printed.
% NETCONF_MODULE_MISSING_ERR Missing essential module %1 in sysrepo
This fatal error message indicates that a module required by Netconf
configuration is not available in the sysrepo repository. The name of