]> git.puffer.fish Git - matthieu/frr.git/commitdiff
mgmtd: clarify the startup dance in comments
authorChristian Hopps <chopps@labn.net>
Thu, 12 Oct 2023 18:38:39 +0000 (14:38 -0400)
committerChristian Hopps <chopps@labn.net>
Thu, 12 Oct 2023 18:38:39 +0000 (14:38 -0400)
Also retry the config read vs. aborting if we haven't got a FE
client connection yet.

Signed-off-by: Christian Hopps <chopps@labn.net>
mgmtd/mgmt.c
mgmtd/mgmt_vty.c

index 77c4473e49f10cb849101f490dffbf6179c6f64c..8d41643065362f83428703236dd5fe04c03029bc 100644 (file)
@@ -52,17 +52,26 @@ void mgmt_init(void)
        /* Initialize the MGMTD Frontend Adapter Module */
        mgmt_fe_adapter_init(mm->master);
 
-       /* Initialize the CLI frontend client */
+       /*
+        * Initialize the CLI frontend client -- this queues an event for the
+        * client to short-circuit connect to the server (ourselves).
+        */
        vty_init_mgmt_fe();
 
-       /* MGMTD VTY commands installation. */
+       /*
+        * MGMTD VTY commands installation -- the frr lib code will queue an
+        * event to read the config files which needs to happen after the
+        * connect from above is made.
+        */
        mgmt_vty_init();
 
        /*
         * Initialize the MGMTD Backend Adapter Module
         *
-        * We do this after the FE stuff so that we always read our config file
-        * prior to any BE connection.
+        * We do this after the FE stuff so that we have read our config file
+        * prior to any BE connection. Setting up the server will queue a
+        * "socket read" event to accept BE connections. So the code is counting
+        * on the above 2 events to run prior to any `accept` event from here.
         */
        mgmt_be_adapter_init(mm->master);
 }
index b49bf80306c1bb14808dff10d26c7deea20b0938..d8f5976f4d6e07db0c88bea1ab19211eb8560d17 100644 (file)
@@ -452,7 +452,14 @@ DEFPY(debug_mgmt, debug_mgmt_cmd,
 
 static void mgmt_config_read_in(struct event *event)
 {
-       mgmt_vty_read_configs();
+       if (vty_mgmt_fe_enabled())
+               mgmt_vty_read_configs();
+       else {
+               zlog_warn("%s: no connection to front-end server, retry in 1s",
+                         __func__);
+               event_add_timer(mm->master, mgmt_config_read_in, NULL, 1,
+                               &mgmt_daemon_info->read_in);
+       }
 }
 
 void mgmt_vty_init(void)