]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3435] add exception handling for module changes
authorAndrei Pavel <andrei@isc.org>
Mon, 27 May 2024 14:47:42 +0000 (17:47 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 20 Jun 2024 17:00:45 +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 6299017c43825d7097b84a4af7c39e89adfda5e5..83dcaf7affb621d8db0ff7306d9a8a14a0baa749 100644 (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));
index c1913ae88979f3283be01dce577cb4a273011214..e480b20e698e65aa8b4218820a537c87397e5766 100644 (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",
index 594c0c85390b127cf3b2a56d31226d3ec0517e77..0568b32324f8558c6b81f1565f04b69c63165fe2 100644 (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;
index 43c17e34536398c317688d50de44bb9effe053ab..ca68f70fb898c51a76c392293b8a8b7c30745748 100644 (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