BIND 10 master, updated. 46cd22e159df5387c036e285e8398e9f1320e2b4 bug #1819: Add manpage note that the --no-kill option was introduced for testing

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Mar 27 08:00:42 UTC 2012


The branch, master has been updated
       via  46cd22e159df5387c036e285e8398e9f1320e2b4 (commit)
       via  ad40537d9f91fcf489d3e9a313a73385ed5fb241 (commit)
       via  6353f50a59f621f96a3ccf0003e5ecd527dcd07c (commit)
       via  d2661eddfcbca6532d6cbe18954d345ab8566345 (commit)
       via  a02f49d16d40c8b38514af00b62001225f9f7a6d (commit)
       via  774aee5f844849e58608ca86bec27e731c3eac5b (commit)
       via  194ef6477663b3c8671724bb6ab7b0bb13ae0b09 (commit)
       via  631e9f192cf33fb58c0a945ef57592fe7813eaa8 (commit)
       via  c6fc5883c41ed20f77ebaea543057521f76fe4d9 (commit)
       via  b3388dfb13dffdd653139673eceef34824eab072 (commit)
       via  774554f46b20ca5ec2ef6c6d5e608114f14e2102 (commit)
      from  0e9213727bb177ede9253fa8d0c1e1316487e33b (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 46cd22e159df5387c036e285e8398e9f1320e2b4
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Mar 27 13:21:47 2012 +0530

    bug #1819: Add manpage note that the --no-kill option was introduced for testing

commit ad40537d9f91fcf489d3e9a313a73385ed5fb241
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Mar 26 11:36:00 2012 +0530

    bug #1819: Add some comments to testcases

commit 6353f50a59f621f96a3ccf0003e5ecd527dcd07c
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Mar 26 11:32:57 2012 +0530

    bug #1819: Check that BoB doesn't kill during shutdown when asked not to

commit d2661eddfcbca6532d6cbe18954d345ab8566345
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Mar 26 11:22:24 2012 +0530

    bug #1819: Add testcase for --no-kill and -i options handling

commit a02f49d16d40c8b38514af00b62001225f9f7a6d
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Mar 23 17:27:32 2012 +0530

    bug #1819: Document --no-kill option in bind10 manpage

commit 774aee5f844849e58608ca86bec27e731c3eac5b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Mar 23 17:27:08 2012 +0530

    bug #1819: Update help text for no-kill option

commit 194ef6477663b3c8671724bb6ab7b0bb13ae0b09
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Mar 23 17:20:12 2012 +0530

    bug #1819: Rename --no-kill-i option to --no-kill

commit 631e9f192cf33fb58c0a945ef57592fe7813eaa8
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Mar 27 13:27:44 2012 +0530

    bug #1819: Add ChangeLog entry

commit c6fc5883c41ed20f77ebaea543057521f76fe4d9
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Mar 22 15:46:39 2012 +0530

    bug #1819: Pass nokill as an argument to BoB constructor

commit b3388dfb13dffdd653139673eceef34824eab072
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Mar 21 16:42:12 2012 +0530

    bug #1819: Change conjunction used in help message

commit 774554f46b20ca5ec2ef6c6d5e608114f14e2102
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Mar 21 16:35:28 2012 +0530

    bug #1819: Add boss nokill flag (-i/--no-kill-i)

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

Summary of changes:
 ChangeLog                              |    6 +++
 src/bin/bind10/bind10.xml              |   12 ++++++
 src/bin/bind10/bind10_src.py.in        |   51 +++++++++++++++-----------
 src/bin/bind10/tests/bind10_test.py.in |   63 ++++++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+), 22 deletions(-)

-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 7c54bf6..b9840be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+411.   [func]          muks
+	Add a -i/--no-kill command-line argument to bind10, which stops
+	it from sending SIGTERM and SIGKILL to other b10 processes when
+	they're shutting down.
+	(Trac #1819, git 774554f46b20ca5ec2ef6c6d5e608114f14e2102)
+
 410.	[bug]		jinmei
 	Python CC library now ensures write operations transmit all given
 	data (unless an error happens).  Previously it didn't check the
diff --git a/src/bin/bind10/bind10.xml b/src/bin/bind10/bind10.xml
index 1f3cb68..c86ce83 100644
--- a/src/bin/bind10/bind10.xml
+++ b/src/bin/bind10/bind10.xml
@@ -45,6 +45,7 @@
     <cmdsynopsis>
       <command>bind10</command>
       <arg><option>-c <replaceable>config-filename</replaceable></option></arg>
+      <arg><option>-i</option></arg>
       <arg><option>-m <replaceable>file</replaceable></option></arg>
       <arg><option>-n</option></arg>
       <arg><option>-p <replaceable>data_path</replaceable></option></arg>
@@ -56,6 +57,7 @@
       <arg><option>--data-path</option> <replaceable>directory</replaceable></arg>
       <arg><option>--msgq-socket-file <replaceable>file</replaceable></option></arg>
       <arg><option>--no-cache</option></arg>
+      <arg><option>--no-kill</option></arg>
       <arg><option>--pid-file</option> <replaceable>filename</replaceable></arg>
       <arg><option>--pretty-name <replaceable>name</replaceable></option></arg>
       <arg><option>--user <replaceable>user</replaceable></option></arg>
@@ -156,6 +158,16 @@
       </varlistentry>
 
       <varlistentry>
+        <term><option>-i</option>, <option>--no-kill</option></term>
+        <listitem>
+	  <para>When this option is passed, <command>bind10</command>
+	  does not send SIGTERM and SIGKILL signals to modules during
+	  shutdown. (This option was introduced for use during
+	  testing.)</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
         <term><option>-u</option> <replaceable>user</replaceable>, <option>--user</option> <replaceable>name</replaceable></term>
 <!-- TODO: example more detail. -->
         <listitem>
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index edc1b69..d002906 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -167,8 +167,8 @@ 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, wait_time=10):
+    config_filename=None, nocache=False, verbose=False, nokill=False,
+    setuid=None, username=None, cmdctl_port=None, wait_time=10):
         """
             Initialize the Boss of BIND. This is a singleton (only one can run).
         
@@ -208,6 +208,7 @@ class BoB:
         self.uid = setuid
         self.username = username
         self.verbose = verbose
+        self.nokill = nokill
         self.data_path = data_path
         self.config_filename = config_filename
         self.cmdctl_port = cmdctl_port
@@ -702,32 +703,36 @@ class BoB:
         # still not enough.
         time.sleep(1)
         self.reap_children()
-        # next try sending a SIGTERM
-        components_to_stop = list(self.components.values())
-        for component in components_to_stop:
-            logger.info(BIND10_SEND_SIGTERM, component.name(), component.pid())
-            try:
-                component.kill()
-            except OSError:
-                # ignore these (usually ESRCH because the child
-                # finally exited)
-                pass
-        # finally, send SIGKILL (unmaskable termination) until everybody dies
-        while self.components:
-            # XXX: some delay probably useful... how much is uncertain
-            time.sleep(0.1)  
-            self.reap_children()
+
+        # Send TERM and KILL signals to modules if we're not prevented
+        # from doing so
+        if not self.nokill:
+            # next try sending a SIGTERM
             components_to_stop = list(self.components.values())
             for component in components_to_stop:
-                logger.info(BIND10_SEND_SIGKILL, component.name(),
-                            component.pid())
+                logger.info(BIND10_SEND_SIGTERM, component.name(), component.pid())
                 try:
-                    component.kill(True)
+                    component.kill()
                 except OSError:
                     # ignore these (usually ESRCH because the child
                     # finally exited)
                     pass
-        logger.info(BIND10_SHUTDOWN_COMPLETE)
+            # finally, send SIGKILL (unmaskable termination) until everybody dies
+            while self.components:
+                # XXX: some delay probably useful... how much is uncertain
+                time.sleep(0.1)
+                self.reap_children()
+                components_to_stop = list(self.components.values())
+                for component in components_to_stop:
+                    logger.info(BIND10_SEND_SIGKILL, component.name(),
+                                component.pid())
+                    try:
+                        component.kill(True)
+                    except OSError:
+                        # ignore these (usually ESRCH because the child
+                        # finally exited)
+                        pass
+            logger.info(BIND10_SHUTDOWN_COMPLETE)
 
     def _get_process_exit_status(self):
         return os.waitpid(-1, os.WNOHANG)
@@ -1043,6 +1048,8 @@ def parse_args(args=sys.argv[1:], Parser=OptionParser):
                       help="UNIX domain socket file the b10-msgq daemon will use")
     parser.add_option("-n", "--no-cache", action="store_true", dest="nocache",
                       default=False, help="disable hot-spot cache in authoritative DNS server")
+    parser.add_option("-i", "--no-kill", action="store_true", dest="nokill",
+                      default=False, help="do not send SIGTERM and SIGKILL signals to modules during shutdown")
     parser.add_option("-u", "--user", dest="user", type="string", default=None,
                       help="Change user after startup (must run as root)")
     parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
@@ -1166,7 +1173,7 @@ 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.verbose, options.nokill, setuid, username,
                            options.cmdctl_port, options.wait_time)
         startup_result = boss_of_bind.startup()
         if startup_result:
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 882824d..fa01d11 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -1012,6 +1012,16 @@ class TestParseArgs(unittest.TestCase):
         options = parse_args(['--config-file=config-file'], TestOptParser)
         self.assertEqual('config-file', options.config_file)
 
+    def test_nokill(self):
+        options = parse_args([], TestOptParser)
+        self.assertEqual(False, options.nokill)
+        options = parse_args(['--no-kill'], TestOptParser)
+        self.assertEqual(True, options.nokill)
+        options = parse_args([], TestOptParser)
+        self.assertEqual(False, options.nokill)
+        options = parse_args(['-i'], TestOptParser)
+        self.assertEqual(True, options.nokill)
+
     def test_cmdctl_port(self):
         """
         Test it can parse the command control port.
@@ -1194,7 +1204,60 @@ class TestBossComponents(unittest.TestCase):
         bob.shutdown()
 
         self.assertTrue(bob.ccs.stopped)
+
+        # Here, killed is an array where False is added if SIGTERM
+        # should be sent, or True if SIGKILL should be sent, in order in
+        # which they're sent.
         self.assertEqual([False, True], killed)
+
+        self.assertTrue(self.__called)
+
+        bob._component_configurator.shutdown = orig
+
+    def test_nokill(self):
+        """
+        Test that the boss *doesn't* kill components which don't want to
+        stop, when asked not to (by passing the --no-kill option which
+        sets bob.nokill to True).
+        """
+        bob = MockBob()
+        bob.nokill = True
+
+        killed = []
+        class ImmortalComponent:
+            """
+            An immortal component. It does not stop when it is told so
+            (anyway it is not told so). It does not die if it is killed
+            the first time. It dies only when killed forcefully.
+            """
+            def kill(self, forceful=False):
+                killed.append(forceful)
+                if forceful:
+                    bob.components = {}
+            def pid(self):
+                return 1
+            def name(self):
+                return "Immortal"
+        bob.components = {}
+        bob.register_process(1, ImmortalComponent())
+
+        # While at it, we check the configurator shutdown is actually called
+        orig = bob._component_configurator.shutdown
+        bob._component_configurator.shutdown = self.__nullary_hook
+        self.__called = False
+
+        bob.ccs = MockModuleCCSession()
+        self.assertFalse(bob.ccs.stopped)
+
+        bob.shutdown()
+
+        self.assertTrue(bob.ccs.stopped)
+
+        # Here, killed is an array where False is added if SIGTERM
+        # should be sent, or True if SIGKILL should be sent, in order in
+        # which they're sent.
+        self.assertEqual([], killed)
+
         self.assertTrue(self.__called)
 
         bob._component_configurator.shutdown = orig



More information about the bind10-changes mailing list