BIND 10 master, updated. 607cbae949553adac7e2a684fa25bda804658f61 Merge branch 'master' into trac1271

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Oct 28 12:41:57 UTC 2011


The branch, master has been updated
       via  607cbae949553adac7e2a684fa25bda804658f61 (commit)
       via  a0e6002f56e624a7cbb48fb06d4ddbc612e315bd (commit)
       via  c3385a5449721914b56448705cae8af449e6d337 (commit)
       via  b10e71aafd6c8b4227083d8e1c87da8878198816 (commit)
       via  25e2cd129a9f7b5a944692152e173dc2896825fb (commit)
       via  d69588a14a8886c02a1510820d69f319171b68c7 (commit)
      from  0a7bd2339e604fb26b7bd94bd8c548b188d60adc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 607cbae949553adac7e2a684fa25bda804658f61
Merge: a0e6002f56e624a7cbb48fb06d4ddbc612e315bd 0a7bd2339e604fb26b7bd94bd8c548b188d60adc
Author: Stephen Morris <stephen at isc.org>
Date:   Fri Oct 28 13:07:17 2011 +0100

    Merge branch 'master' into trac1271

commit a0e6002f56e624a7cbb48fb06d4ddbc612e315bd
Author: Stephen Morris <stephen at isc.org>
Date:   Wed Oct 26 14:14:38 2011 +0100

    [1271] Updated the documentation for the changes

commit c3385a5449721914b56448705cae8af449e6d337
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Oct 24 15:25:19 2011 +0100

    [1271] Altered check on notify_boss message to reflect modified contents

commit b10e71aafd6c8b4227083d8e1c87da8878198816
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Oct 24 14:38:12 2011 +0100

    [1271] Modify the message associated with command/configuration session
    
    The ccsession is not a process, so it should not have a "process started"
    message associated with it.

commit 25e2cd129a9f7b5a944692152e173dc2896825fb
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Oct 24 13:26:20 2011 +0100

    [1271] Enable full debugging on bind10 when -v is enabled
    
    Although -v was passed through to other processes, it did not affect
    the main bind10 process.  -v now enables full debugging on bind10
    when it starts up.

commit d69588a14a8886c02a1510820d69f319171b68c7
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Oct 24 12:51:17 2011 +0100

    [1271] Update Boss to wait for configuration manager
    
    Boss now waits to receive a message from the configuration manager
    to say that it is running before starting other processes.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/bind10/bind10.8                        |   16 +++++-
 src/bin/bind10/bind10.xml                      |   14 +++++
 src/bin/bind10/bind10_messages.mes             |   37 +++++++++++-
 src/bin/bind10/bind10_src.py.in                |   75 ++++++++++++++++++++----
 src/lib/python/isc/config/cfgmgr.py            |    2 +-
 src/lib/python/isc/config/tests/cfgmgr_test.py |    2 +-
 6 files changed, 129 insertions(+), 17 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10.8 b/src/bin/bind10/bind10.8
index 1af4f14..0adcb70 100644
--- a/src/bin/bind10/bind10.8
+++ b/src/bin/bind10/bind10.8
@@ -9,6 +9,15 @@
 .\"
 .TH "BIND10" "8" "August 11, 2011" "BIND10" "BIND10"
 .\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\" -----------------------------------------------------------------
 .\" * set default formatting
 .\" -----------------------------------------------------------------
 .\" disable hyphenation
@@ -22,7 +31,7 @@
 bind10 \- BIND 10 boss process
 .SH "SYNOPSIS"
 .HP \w'\fBbind10\fR\ 'u
-\fBbind10\fR [\fB\-c\ \fR\fB\fIconfig\-filename\fR\fR] [\fB\-m\ \fR\fB\fIfile\fR\fR] [\fB\-n\fR] [\fB\-p\ \fR\fB\fIdata_path\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-\-brittle\fR] [\fB\-\-cmdctl\-port\fR\ \fIport\fR] [\fB\-\-config\-file\fR\ \fIconfig\-filename\fR] [\fB\-\-data\-path\fR\ \fIdirectory\fR] [\fB\-\-msgq\-socket\-file\ \fR\fB\fIfile\fR\fR] [\fB\-\-no\-cache\fR] [\fB\-\-pid\-file\fR\ \fIfilename\fR] [\fB\-\-pretty\-name\ \fR\fB\fIname\fR\fR] [\fB\-\-user\ \fR\fB\fIuser\fR\fR] [\fB\-\-verbose\fR]
+\fBbind10\fR [\fB\-c\ \fR\fB\fIconfig\-filename\fR\fR] [\fB\-m\ \fR\fB\fIfile\fR\fR] [\fB\-n\fR] [\fB\-p\ \fR\fB\fIdata_path\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-w\ \fR\fB\fIwait_time\fR\fR] [\fB\-\-brittle\fR] [\fB\-\-cmdctl\-port\fR\ \fIport\fR] [\fB\-\-config\-file\fR\ \fIconfig\-filename\fR] [\fB\-\-data\-path\fR\ \fIdirectory\fR] [\fB\-\-msgq\-socket\-file\ \fR\fB\fIfile\fR\fR] [\fB\-\-no\-cache\fR] [\fB\-\-pid\-file\fR\ \fIfilename\fR] [\fB\-\-pretty\-name\ \fR\fB\fIname\fR\fR] [\fB\-\-user\ \fR\fB\fIuser\fR\fR] [\fB\-\-verbose\fR] [\fB\-\-wait\ \fR\fB\fIwait_time\fR\fR]
 .SH "DESCRIPTION"
 .PP
 The
@@ -107,6 +116,11 @@ Display more about what is going on for
 \fBbind10\fR
 and its child processes\&.
 .RE
+.PP
+\fB\-w\fR \fIwait_time\fR, \fB\-\-wait\fR \fIwait_time\fR
+.RS 4
+Sets the amount of time that BIND 10 will wait for the configuration manager (a key component of BIND 10) to initialize itself before abandoning the start up and terminating with an error\&. The wait_time is specified in seconds and has a default value of 10\&.
+.RE
 .SH "STATISTICS DATA"
 .PP
 The statistics data collected by the
diff --git a/src/bin/bind10/bind10.xml b/src/bin/bind10/bind10.xml
index b101ba8..6de0947 100644
--- a/src/bin/bind10/bind10.xml
+++ b/src/bin/bind10/bind10.xml
@@ -50,6 +50,7 @@
       <arg><option>-p <replaceable>data_path</replaceable></option></arg>
       <arg><option>-u <replaceable>user</replaceable></option></arg>
       <arg><option>-v</option></arg>
+      <arg><option>-w <replaceable>wait_time</replaceable></option></arg>
       <arg><option>--brittle</option></arg>
       <arg><option>--cmdctl-port</option> <replaceable>port</replaceable></arg>
       <arg><option>--config-file</option> <replaceable>config-filename</replaceable></arg>
@@ -60,6 +61,7 @@
       <arg><option>--pretty-name <replaceable>name</replaceable></option></arg>
       <arg><option>--user <replaceable>user</replaceable></option></arg>
       <arg><option>--verbose</option></arg>
+      <arg><option>--wait <replaceable>wait_time</replaceable></option></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
 
@@ -211,6 +213,18 @@ The default is the basename of ARG 0.
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>-w</option> <replaceable>wait_time</replaceable>, <option>--wait</option> <replaceable>wait_time</replaceable></term>
+        <listitem>
+          <para>Sets the amount of time that BIND 10 will wait for
+          the configuration manager (a key component of BIND 10) to
+          initialize itself before abandoning the start up and
+          terminating with an error.  The wait_time is specified in
+          seconds and has a default value of 10.
+          </para>
+        </listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
diff --git a/src/bin/bind10/bind10_messages.mes b/src/bin/bind10/bind10_messages.mes
index 4debcdb..2769aa9 100644
--- a/src/bin/bind10/bind10_messages.mes
+++ b/src/bin/bind10/bind10_messages.mes
@@ -28,6 +28,10 @@ started according to the configuration.
 This message shows whether or not the resolver should be
 started according to the configuration.
 
+% BIND10_INVALID_STATISTICS_DATA invalid specification of statistics data specified
+An error was encountered when the boss module specified
+statistics data which is invalid for the boss specification file.
+
 % BIND10_INVALID_USER invalid user: %1
 The boss process was started with the -u option, to drop root privileges
 and continue running as the specified user, but the user is unknown.
@@ -157,6 +161,10 @@ indicated OS API function with given error.
 % BIND10_SOCKET_GET requesting socket [%1]:%2 of type %3 from the creator
 The boss forwards a request for a socket to the socket creator.
 
+% BIND10_STARTED_CC started configuration/command session
+Debug message given when BIND 10 has successfull started the object that
+handles configuration and commands.
+
 % BIND10_STARTED_PROCESS started %1
 The given process has successfully been started.
 
@@ -166,6 +174,10 @@ The given process has successfully been started, and has the given PID.
 % BIND10_STARTING starting BIND10: %1
 Informational message on startup that shows the full version.
 
+% BIND10_STARTING_CC starting configuration/command session
+Informational message given when BIND 10 is starting the session object
+that handles configuration and commands.
+
 % BIND10_STARTING_PROCESS starting process %1
 The boss module is starting the given process.
 
@@ -184,6 +196,18 @@ All modules have been successfully started, and BIND 10 is now running.
 There was a fatal error when BIND10 was trying to start. The error is
 shown, and BIND10 will now shut down.
 
+% BIND10_STARTUP_UNEXPECTED_MESSAGE unrecognised startup message %1
+During the startup process, a number of messages are exchanged between the
+Boss process and the processes it starts.  This error is output when a
+message received by the Boss process is recognised as being of the
+correct format but is unexpected.  It may be that processes are starting
+of sequence.
+
+% BIND10_STARTUP_UNRECOGNISED_MESSAGE unrecognised startup message %1
+During the startup process, a number of messages are exchanged between the
+Boss process and the processes it starts.  This error is output when a
+message received by the Boss process is not recognised.
+
 % BIND10_START_AS_NON_ROOT starting %1 as a user, not root. This might fail.
 The given module is being started or restarted without root privileges.
 If the module needs these privileges, it may have problems starting.
@@ -199,6 +223,13 @@ the message channel.
 An unknown child process has exited. The PID is printed, but no further
 action will be taken by the boss process.
 
-% BIND10_INVALID_STATISTICS_DATA invalid specification of statistics data specified
-An error was encountered when the boss module specified
-statistics data which is invalid for the boss specification file.
+% BIND10_WAIT_CFGMGR waiting for configuration manager process to initialize
+The configuration manager process is so critical to operation of BIND 10
+that after starting it, the Boss module will wait for it to initialize
+itself before continuing.  This debug message is produced during the
+wait and may be output zero or more times depending on how long it takes
+the configuration manager to start up.  The total length of time Boss
+will wait for the configuration manager before reporting an error is
+set with the command line --wait switch, which has a default value of
+ten seconds.
+
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index 22309d6..235bba5 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -211,12 +211,14 @@ class ProcessInfo:
 
 class CChannelConnectError(Exception): pass
 
+class ProcessStartError(Exception): pass
+
 class BoB:
     """Boss of BIND class."""
     
     def __init__(self, msgq_socket_file=None, data_path=None,
     config_filename=None, nocache=False, verbose=False, setuid=None,
-    username=None, cmdctl_port=None, brittle=False):
+    username=None, cmdctl_port=None, brittle=False, wait_time=10):
         """
             Initialize the Boss of BIND. This is a singleton (only one can run).
         
@@ -224,11 +226,18 @@ class BoB:
             msgq process listens on.  If verbose is True, then the boss reports
             what it is doing.
 
-            Data path and config filename are passed trough to config manager
+            Data path and config filename are passed through to config manager
             (if provided) and specify the config file to be used.
 
             The cmdctl_port is passed to cmdctl and specify on which port it
             should listen.
+
+            brittle is a debug option that controls whether the Boss shuts down
+            after any process dies.
+
+            wait_time controls the amount of time (in seconds) that Boss waits
+            for selected processes to initialize before continuing with the
+            initialization.  Currently this is only the configuration manager.
         """
         self.cc_session = None
         self.ccs = None
@@ -252,8 +261,13 @@ class BoB:
         self.config_filename = config_filename
         self.cmdctl_port = cmdctl_port
         self.brittle = brittle
+        self.wait_time = wait_time
         self.sockcreator = None
 
+        # If -v was set, enable full debug logging.
+        if self.verbose:
+            logger.set_severity("DEBUG", 99)
+
     def config_handler(self, new_config):
         # If this is initial update, don't do anything now, leave it to startup
         if not self.runnable:
@@ -440,6 +454,27 @@ class BoB:
         else:
             logger.debug(DBG_PROCESS, BIND10_STARTED_PROCESS_PID, self.curproc, pid)
 
+    def process_running(self, msg, who):
+        """
+            Some processes return a message to the Boss after they have
+            started to indicate that they are running.  The form of the
+            message is a dictionary with contents {"running:", "<process>"}.
+            This method checks the passed message and returns True if the
+            "who" process is contained in the message (so is presumably
+            running).  It returns False for all other conditions and will
+            log an error if appropriate.
+        """
+        if msg is not None:
+            try:
+                if msg["running"] == who:
+                    return True
+                else:
+                    logger.error(BIND10_STARTUP_UNEXPECTED_MESSAGE, msg)
+            except:
+                logger.error(BIND10_STARTUP_UNRECOGNISED_MESSAGE, msg)
+        
+        return False
+
     # The next few methods start the individual processes of BIND-10.  They
     # are called via start_all_processes().  If any fail, an exception is
     # raised which is caught by the caller of start_all_processes(); this kills
@@ -470,6 +505,10 @@ class BoB:
             except isc.cc.session.SessionError:
                 time.sleep(0.1)
 
+        # Subscribe to the message queue.  The only messages we expect to receive
+        # on this channel are once relating to process startup.
+        self.cc_session.group_subscribe("Boss")
+
     def start_cfgmgr(self, c_channel_env):
         """
             Starts the configuration manager process
@@ -487,11 +526,18 @@ class BoB:
         self.processes[bind_cfgd.pid] = bind_cfgd
         self.log_started(bind_cfgd.pid)
 
-        # sleep until b10-cfgmgr is fully up and running, this is a good place
-        # to have a (short) timeout on synchronized groupsend/receive
-        # TODO: replace the sleep by a listen for ConfigManager started
-        # message
-        time.sleep(1)
+        # Wait for the configuration manager to start up as subsequent initialization
+        # cannot proceed without it.  The time to wait can be set on the command line.
+        time_remaining = self.wait_time
+        msg, env = self.cc_session.group_recvmsg()
+        while time_remaining > 0 and not self.process_running(msg, "ConfigManager"):
+            logger.debug(DBG_PROCESS, BIND10_WAIT_CFGMGR)
+            time.sleep(1)
+            time_remaining = time_remaining - 1
+            msg, env = self.cc_session.group_recvmsg()
+        
+        if not self.process_running(msg, "ConfigManager"):
+            raise ProcessStartError("Configuration manager process has not started")
 
     def start_ccsession(self, c_channel_env):
         """
@@ -499,14 +545,17 @@ class BoB:
 
             The argument c_channel_env is unused but is supplied to keep the
             argument list the same for all start_xxx methods.
+
+            With regards to logging, note that as the CC session is not a
+            process, the log_starting/log_started methods are not used.
         """
-        self.log_starting("ccsession")
+        logger.info(BIND10_STARTING_CC)
         self.ccs = isc.config.ModuleCCSession(SPECFILE_LOCATION, 
                                       self.config_handler,
                                       self.command_handler,
                                       socket_file = self.msgq_socket_file)
         self.ccs.start()
-        self.log_started()
+        logger.debug(DBG_PROCESS, BIND10_STARTED_CC)
 
     # A couple of utility methods for starting processes...
 
@@ -644,7 +693,8 @@ class BoB:
         self.start_ccsession(c_channel_env)
 
         # Extract the parameters associated with Bob.  This can only be
-        # done after the CC Session is started.
+        # done after the CC Session is started.  Note that the logging
+        # configuration may override the "-v" switch set on the command line.
         self.read_bind10_config()
 
         # Continue starting the processes.  The authoritative server (if
@@ -956,6 +1006,8 @@ def parse_args(args=sys.argv[1:], Parser=OptionParser):
                       help="file to dump the PID of the BIND 10 process")
     parser.add_option("--brittle", dest="brittle", action="store_true",
                       help="debugging flag: exit if any component dies")
+    parser.add_option("-w", "--wait", dest="wait_time", type="int",
+                      default=10, help="Time (in seconds) to wait for config manager to start up")
 
     (options, args) = parser.parse_args(args)
 
@@ -1058,7 +1110,8 @@ def main():
     # Go bob!
     boss_of_bind = BoB(options.msgq_socket_file, options.data_path,
                        options.config_file, options.nocache, options.verbose,
-                       setuid, username, options.cmdctl_port, options.brittle)
+                       setuid, username, options.cmdctl_port, options.brittle,
+                       options.wait_time)
     startup_result = boss_of_bind.startup()
     if startup_result:
         logger.fatal(BIND10_STARTUP_ERROR, startup_result)
diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py
index 9996a19..88c0ee8 100644
--- a/src/lib/python/isc/config/cfgmgr.py
+++ b/src/lib/python/isc/config/cfgmgr.py
@@ -202,7 +202,7 @@ class ConfigManager:
 
     def notify_boss(self):
         """Notifies the Boss module that the Config Manager is running"""
-        self.cc.group_sendmsg({"running": "configmanager"}, "Boss")
+        self.cc.group_sendmsg({"running": "ConfigManager"}, "Boss")
 
     def set_module_spec(self, spec):
         """Adds a ModuleSpec"""
diff --git a/src/lib/python/isc/config/tests/cfgmgr_test.py b/src/lib/python/isc/config/tests/cfgmgr_test.py
index eacc425..c8df3b6 100644
--- a/src/lib/python/isc/config/tests/cfgmgr_test.py
+++ b/src/lib/python/isc/config/tests/cfgmgr_test.py
@@ -128,7 +128,7 @@ class TestConfigManager(unittest.TestCase):
         msg = self.fake_session.get_message("Boss", None)
         self.assert_(msg)
         # this one is actually wrong, but 'current status quo'
-        self.assertEqual(msg, {"running": "configmanager"})
+        self.assertEqual(msg, {"running": "ConfigManager"})
 
     def test_set_module_spec(self):
         module_spec = isc.config.module_spec.module_spec_from_file(self.data_path + os.sep + "spec1.spec")




More information about the bind10-changes mailing list