From: Andrei Pavel Date: Mon, 27 May 2024 14:47:42 +0000 (+0300) Subject: [#3435] add exception handling for module changes X-Git-Tag: Kea-2.7.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cae551ae9ba09e3d1f36372726c10a85bc2b1489;p=thirdparty%2Fkea.git [#3435] add exception handling for module changes --- diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index 6299017c43..83dcaf7aff 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -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)); } catch (exception const& ex) { ostringstream msg; @@ -484,7 +490,8 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) { optional 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)); diff --git a/src/bin/netconf/netconf_messages.cc b/src/bin/netconf/netconf_messages.cc index c1913ae889..e480b20e69 100644 --- a/src/bin/netconf/netconf_messages.cc +++ b/src/bin/netconf/netconf_messages.cc @@ -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", diff --git a/src/bin/netconf/netconf_messages.h b/src/bin/netconf/netconf_messages.h index 594c0c8539..0568b32324 100644 --- a/src/bin/netconf/netconf_messages.h +++ b/src/bin/netconf/netconf_messages.h @@ -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; diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes index 43c17e3453..ca68f70fb8 100644 --- a/src/bin/netconf/netconf_messages.mes +++ b/src/bin/netconf/netconf_messages.mes @@ -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