Fix logic bug in rev 2072
authorIustin Pop <iustin@google.com>
Thu, 27 Nov 2008 10:21:46 +0000 (10:21 +0000)
committerIustin Pop <iustin@google.com>
Thu, 27 Nov 2008 10:21:46 +0000 (10:21 +0000)
In revision 2072 "ConfigWriter: change cluster serial meaning" I misread
the serial_no update logic: it was about updating the serial number on
the object itself, not on the cluster.

So we don't actually have at all cluster serial number increase when a
node is changed (not removed/added).

This patch revers to the original always increase the target serial
number and adds increase of the cluster serial number in case a node has
been changed.

Reviewed-by: ultrotter

lib/config.py

index 739f761..1101e41 100644 (file)
@@ -954,21 +954,24 @@ class ConfigWriter:
     if self._config_data is None:
       raise errors.ProgrammerError("Configuration file not read,"
                                    " cannot save.")
-    update_serial = True
+    update_serial = False
     if isinstance(target, objects.Cluster):
       test = target == self._config_data.cluster
     elif isinstance(target, objects.Node):
       test = target in self._config_data.nodes.values()
+      update_serial = True
     elif isinstance(target, objects.Instance):
       test = target in self._config_data.instances.values()
-      update_serial = False
     else:
       raise errors.ProgrammerError("Invalid object type (%s) passed to"
                                    " ConfigWriter.Update" % type(target))
     if not test:
       raise errors.ConfigurationError("Configuration updated since object"
                                       " has been read or unknown object")
+    target.serial_no += 1
+
     if update_serial:
-      target.serial_no += 1
+      # for node updates, we need to increase the cluster serial too
+      self._config_data.cluster.serial_no += 1
 
     self._WriteConfig()