BIND 10 trac213-incremental, updated. af0b62cf1161739d3a1244750b60d3e6b75a22e8 [213] Documentation regarding configurator behavior

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 31 16:42:38 UTC 2011


The branch, trac213-incremental has been updated
       via  af0b62cf1161739d3a1244750b60d3e6b75a22e8 (commit)
       via  b64ab304aa90d938003922c95926ef1b0ea4fec9 (commit)
       via  4e0d6d115cd572e58b886bcaffee3f1df7b6bcad (commit)
       via  4493013b75994f8689a26951592fb575a23e5b35 (commit)
       via  8df7345ad6d658c6a366499b6e491790289168ed (commit)
       via  f0ad44ee4a8bc33ea2109d91243d95db1833659a (commit)
      from  3f070803d6d61ffbbda0f6628bb2d7f0cfdb6ca0 (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 af0b62cf1161739d3a1244750b60d3e6b75a22e8
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 12:32:21 2011 +0100

    [213] Documentation regarding configurator behavior

commit b64ab304aa90d938003922c95926ef1b0ea4fec9
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 12:02:33 2011 +0100

    [213] Editorial change

commit 4e0d6d115cd572e58b886bcaffee3f1df7b6bcad
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 12:01:25 2011 +0100

    [213] Unify config and spec

commit 4493013b75994f8689a26951592fb575a23e5b35
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 11:51:26 2011 +0100

    [213] More documentation and style fixes

commit 8df7345ad6d658c6a366499b6e491790289168ed
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 11:26:57 2011 +0100

    [213] Documentation about badly stopped state

commit f0ad44ee4a8bc33ea2109d91243d95db1833659a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 31 11:04:54 2011 +0100

    [213] Document it allows process tu start more than once

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

Summary of changes:
 src/lib/python/isc/bind10/component.py            |   73 ++++++++++++++++-----
 src/lib/python/isc/bind10/tests/component_test.py |    8 +-
 2 files changed, 59 insertions(+), 22 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/bind10/component.py b/src/lib/python/isc/bind10/component.py
index 1c2a75a..789ef45 100644
--- a/src/lib/python/isc/bind10/component.py
+++ b/src/lib/python/isc/bind10/component.py
@@ -20,6 +20,11 @@ of component) and shutting down. It also handles the configuration of this.
 
 Dependencies between them are not yet handled. It might turn out they are
 needed, in that case they will be added sometime in future.
+
+This framework allows for a single process to be started multiple times (by
+specifying multiple components with the same configuration). However, the rest
+of the system might not handle such situation well, so until it is made so,
+it would be better to start each process at most once.
 """
 
 import isc.log
@@ -78,6 +83,11 @@ class Component:
                     | kind == core or kind == needed and it failed too soon
                     v
                   Dead
+
+    Note that there are still situations which are not handled properly here.
+    We don't recognize a component that is starting up, but not ready yet, one
+    that is already shutting down, impossible to stop, etc. We need to add more
+    states in future to handle it properly.
     """
     def __init__(self, process, boss, kind, address=None, params=None):
         """
@@ -110,12 +120,20 @@ class Component:
         if kind not in ['core', 'needed', 'dispensable']:
             raise ValueError('Component kind can not be ' + kind)
         self.__state = STATE_STOPPED
+        # These should be read-only
         self._kind = kind
         self._boss = boss
         self._process = process
+        # This can be overwritten/set by the child classes
         self._start_func = None
         self._address = address
         self._params = params
+        # These should be considered private. It is protected to
+        # allow tests in and for really rare ocassions, but a care
+        # should be taken to understand the Component code.
+        #
+        # It should not be accessed when the component wasn't run
+        # yet.
         self._procinfo = None
 
     def start(self):
@@ -153,8 +171,10 @@ class Component:
         boss.start_simple is performed.
 
         If you override the method completely, you should consider overriding
-        pid and _stop_internal (and possibly _failed_internal and name) as well.
-        You should also register any processes started within boss.
+        pid, _stop_internal (and possibly _failed_internal and name) and kill
+        as well. You should also register any processes started within boss.
+        (In fact, you could set the _procinfo variable and use the provided
+        ones, but then you are OK with providing _start_func anyway).
         """
         # This one is not tested. For one, it starts a real process
         # which is out of scope of unit tests, for another, it just
@@ -192,8 +212,13 @@ class Component:
         You can replace this method if you want a different way to do it.
 
         If you're overriding this one, you probably want to replace the
-        _start_internal and pid methods (and maybe _failed_internal and
+        _start_internal, kill and pid methods (and maybe _failed_internal and
         name as well).
+
+        Also, note that it is a bad idea to raise exceptions from here.
+        Under such circumstance, the component will be considered stopped,
+        and the exception propagated, but we can't be sure it really is
+        dead.
         """
         self._boss.stop_process(self._process, self._address)
         # TODO Some way to wait for the process that doesn't want to
@@ -272,8 +297,13 @@ class Component:
 
         You probably want to override this method if you're providing custom
         _start_internal.
+
+        Note that some components preserve the pid after a call to stop or
+        failed. This is because the components need to preserve it in order
+        to be able to kill the process if it failed to stop properly. Therefore
+        you should not rely on the pid being None if the component is stopped.
         """
-        return self._procinfo.pid if self._procinfo else None
+        return self._procinfo.pid if self._procinfo is not None else None
 
     def kill(self, forcefull=False):
         """
@@ -285,7 +315,7 @@ class Component:
 
         If the forcefull is true, it uses SIGKILL instead of SIGTERM.
         """
-        if self._procinfo:
+        if self._procinfo is not None:
             if forcefull:
                 self._procinfo.process.kill()
             else:
@@ -300,7 +330,8 @@ class Configurator:
     Note that this will allow you to stop (by invoking reconfigure) a core
     component. There should be some kind of layer protecting users from ever
     doing so (users must not stop the config manager, message queue and stuff
-    like that or the system won't start again).
+    like that or the system won't start again). However, if a user specifies
+    b10-auth as core, it is safe to stop that one.
 
     The parameters are:
     * `boss`: The boss we are managing for.
@@ -369,6 +400,11 @@ class Configurator:
     def shutdown(self):
         """
         Shuts everything down.
+
+        It is not expected that anyone would want to shutdown and then start
+        the configurator again, so we don't explicitly make sure that would
+        work. However, we are not avare of anything that would make it not
+        work either.
         """
         if not self._running:
             raise ValueError("Trying to shutdown the component " +
@@ -424,27 +460,27 @@ class Configurator:
                                                   ' a running component is ' +
                                                   'not yet supported. Remove' +
                                                   ' and re-add ' + cname +
-                                                  'to get the same effect')
+                                                  ' to get the same effect')
         # Handle introduction of new components
         plan_add = []
         for cname in new.keys():
             if cname not in old:
-                component_spec = new[cname]
+                component_config = new[cname]
                 creator = Component
-                if 'special' in component_spec:
+                if 'special' in component_config:
                     # TODO: Better error handling
-                    creator = self.__specials[component_spec['special']]
-                component = creator(component_spec.get('process', cname),
-                                    self.__boss, component_spec['kind'],
-                                    component_spec.get('address'),
-                                    component_spec.get('params'))
-                priority = component_spec.get('priority', 0)
+                    creator = self.__specials[component_config['special']]
+                component = creator(component_config.get('process', cname),
+                                    self.__boss, component_config['kind'],
+                                    component_config.get('address'),
+                                    component_config.get('params'))
+                priority = component_config.get('priority', 0)
                 # We store tuples, priority first, so we can easily sort
                 plan_add.append((priority, {
                     'component': component,
                     'command': START_CMD,
                     'name': cname,
-                    'spec': component_spec
+                    'config': component_config
                 }))
         # Push the starts there sorted by priority
         plan.extend([command for (_, command) in sorted(plan_add,
@@ -475,7 +511,7 @@ class Configurator:
         at last 'component' (a component object to work with) and 'command'
         (the command to do). Currently, both existing commands need 'name' of
         the component as well (the identifier from configuration). The 'start'
-        one needs the 'spec' to be there, which is the configuration description
+        one needs the 'config' to be there, which is the configuration description
         of the component.
         """
         done = 0
@@ -488,7 +524,8 @@ class Configurator:
                              command, component.name())
                 if command == START_CMD:
                     component.start()
-                    self._components[task['name']] = (task['spec'], component)
+                    self._components[task['name']] = (task['config'],
+                                                      component)
                 elif command == STOP_CMD:
                     if component.running():
                         component.stop()
diff --git a/src/lib/python/isc/bind10/tests/component_test.py b/src/lib/python/isc/bind10/tests/component_test.py
index 797b835..ac94ea3 100644
--- a/src/lib/python/isc/bind10/tests/component_test.py
+++ b/src/lib/python/isc/bind10/tests/component_test.py
@@ -557,25 +557,25 @@ class ConfiguratorTest(BossUtils, unittest.TestCase):
                 'component': stopped,
                 'command': 'start',
                 'name': 'first',
-                'spec': {'a': 1}
+                'config': {'a': 1}
             },
             {
                 'component': started,
                 'command': 'stop',
                 'name': 'second',
-                'spec': {}
+                'config': {}
             },
             {
                 'component': FailComponent('third', self, 'needed'),
                 'command': 'start',
                 'name': 'third',
-                'spec': {}
+                'config': {}
             },
             {
                 'component': self.__component_test('fourth', self, 'core'),
                 'command': 'start',
                 'name': 'fourth',
-                'spec': {}
+                'config': {}
             }
         ]
         # Don't include the preparation into the log




More information about the bind10-changes mailing list