]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: add NB phase-specific error codes
authorEmanuele Di Pascale <emanuele@voltanet.io>
Fri, 9 Nov 2018 15:13:12 +0000 (16:13 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:15:26 +0000 (15:15 +0100)
As suggested by Renato, add error codes that are specific
to the various phases of a northbound callback. These can
be used by the daemons when logging an error. The reasoning
is that validation errors typically mean that there is an
inconsistency in the configuration, a prepare error means
that we are running out of resources, and abort/apply errors
are bugs that need to be reported to the devs.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
lib/lib_errors.c
lib/lib_errors.h
lib/northbound.c

index b1ed7d2f6b15f159696996b153ac34060a5127fd..7e428f135c4bbce018489d562c0b55527dbb1c30 100644 (file)
@@ -105,10 +105,16 @@ static struct log_ref ferr_lib_warn[] = {
                .suggestion = "Check if the installed FRR YANG modules are in sync with the FRR binaries",
        },
        {
-               .code = EC_LIB_NB_CB_CONFIG,
-               .title = "A northbound configuration callback has failed",
-               .description = "The northbound subsystem has detected that a callback used to process a configuration change has returned an error",
-               .suggestion = "The log message should contain further details on the specific error that occurred; investigate the reported error.",
+               .code = EC_LIB_NB_CB_CONFIG_VALIDATE,
+               .title = "A northbound configuration callback has failed in the VALIDATE phase",
+               .description = "A callback used to process a configuration change has returned a validation error",
+               .suggestion = "The provided configuration is invalid. Fix any inconsistency and try again.",
+       },
+       {
+               .code = EC_LIB_NB_CB_CONFIG_PREPARE,
+               .title = "A northbound configuration callback has failed in the PREPARE phase",
+               .description = "A callback used to process a configuration change has returned a resource allocation error",
+               .suggestion = "The system might be running out of resources. Check the log for more details.",
        },
        {
                .code = EC_LIB_NB_CB_STATE,
@@ -326,6 +332,18 @@ static struct log_ref ferr_lib_err[] = {
                .description = "The northbound subsystem has detected that the libsysrepo library returned an error",
                .suggestion = "Open an Issue with all relevant log files and restart FRR"
        },
+       {
+               .code = EC_LIB_NB_CB_CONFIG_ABORT,
+               .title = "A northbound configuration callback has failed in the ABORT phase",
+               .description = "A callback used to process a configuration change has returned an error while trying to abort a change",
+               .suggestion = "Gather log data and open an Issue.",
+       },
+       {
+               .code = EC_LIB_NB_CB_CONFIG_APPLY,
+               .title = "A northbound configuration callback has failed in the APPLY phase",
+               .description = "A callback used to process a configuration change has returned an error while applying the changes",
+               .suggestion = "Gather log data and open an Issue.",
+       },
        {
                .code = END_FERR,
        }
index 5534edbd8d9faf2b310c74346355b139d612a090..86a83df46c216ae19f406d3dc1109b26efb55c14 100644 (file)
@@ -57,7 +57,10 @@ enum lib_log_refs {
        EC_LIB_NB_CB_MISSING,
        EC_LIB_NB_CB_INVALID_PRIO,
        EC_LIB_NB_CBS_VALIDATION,
-       EC_LIB_NB_CB_CONFIG,
+       EC_LIB_NB_CB_CONFIG_VALIDATE,
+       EC_LIB_NB_CB_CONFIG_PREPARE,
+       EC_LIB_NB_CB_CONFIG_ABORT,
+       EC_LIB_NB_CB_CONFIG_APPLY,
        EC_LIB_NB_CB_STATE,
        EC_LIB_NB_CB_RPC,
        EC_LIB_NB_CANDIDATE_INVALID,
index 09aa60b1d2b43f05c1dc3f26d3100e8ca5f2c9b5..a7f9c8620ef9e57c5fa1331bca35471e2023bc0a 100644 (file)
@@ -719,6 +719,7 @@ static int nb_configuration_callback(const enum nb_event event,
        const struct lyd_node *dnode = change->cb.dnode;
        union nb_resource *resource;
        int ret = NB_ERR;
+       enum lib_log_refs ref;
 
        if (debug_northbound) {
                const char *value = "(none)";
@@ -751,12 +752,36 @@ static int nb_configuration_callback(const enum nb_event event,
                break;
        }
 
-       if (ret != NB_OK)
-               flog_warn(
-                       EC_LIB_NB_CB_CONFIG,
-                       "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]",
-                       __func__, nb_err_name(ret), nb_event_name(event),
-                       nb_operation_name(operation), xpath);
+       if (ret != NB_OK) {
+               switch (event) {
+               case NB_EV_VALIDATE:
+                       ref = EC_LIB_NB_CB_CONFIG_VALIDATE;
+                       break;
+               case NB_EV_PREPARE:
+                       ref = EC_LIB_NB_CB_CONFIG_PREPARE;
+                       break;
+               case NB_EV_ABORT:
+                       ref = EC_LIB_NB_CB_CONFIG_ABORT;
+                       break;
+               case NB_EV_APPLY:
+                       ref = EC_LIB_NB_CB_CONFIG_APPLY;
+                       break;
+               }
+               if (event == NB_EV_VALIDATE || event == NB_EV_PREPARE)
+                       flog_warn(
+                               ref,
+                               "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]",
+                               __func__, nb_err_name(ret),
+                               nb_event_name(event),
+                               nb_operation_name(operation), xpath);
+               else
+                       flog_err(
+                               ref,
+                               "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]",
+                               __func__, nb_err_name(ret),
+                               nb_event_name(event),
+                               nb_operation_name(operation), xpath);
+       }
 
        return ret;
 }