Skip to content
Snippets Groups Projects
Commit cff4c037 authored by Iustin Pop's avatar Iustin Pop
Browse files

ConfigWriter: change cluster serial meaning

Currently, we increase the cluster serial number for instance additions,
removals and renames. This is conforming with the REST paradigm, however
it means that for each of these operations, we need to push ssconf
updates to all nodes.

In order to support future cases with reduced set of master-eligible
nodes, we want to reduce the ssconf pushes (which need to be to all
nodes). This patch changes the meaning for the cluster serial number so
that it doesn't track instance operations at all.

This means that addition of an instance can fail due to concurrent
additions, even if the cluster serial has not changed. It slightly
breaks the REST paradigm, but IMHO it's better for actual usage.

Reviewed-by: ultrotter
parent 50a707fa
No related branches found
No related tags found
No related merge requests found
......@@ -537,7 +537,6 @@ class ConfigWriter:
instance.serial_no = 1
self._config_data.instances[instance.name] = instance
self._config_data.cluster.serial_no += 1
self._WriteConfig()
def _SetInstanceStatus(self, instance_name, status):
......@@ -573,7 +572,6 @@ class ConfigWriter:
if instance_name not in self._config_data.instances:
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name)
del self._config_data.instances[instance_name]
self._config_data.cluster.serial_no += 1
self._WriteConfig()
@locking.ssynchronized(_config_lock)
......@@ -601,7 +599,6 @@ class ConfigWriter:
disk.iv_name))
self._config_data.instances[inst.name] = inst
self._config_data.cluster.serial_no += 1
self._WriteConfig()
@locking.ssynchronized(_config_lock)
......@@ -957,18 +954,21 @@ class ConfigWriter:
if self._config_data is None:
raise errors.ProgrammerError("Configuration file not read,"
" cannot save.")
update_serial = True
if isinstance(target, objects.Cluster):
test = target == self._config_data.cluster
elif isinstance(target, objects.Node):
test = target in self._config_data.nodes.values()
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
self._WriteConfig()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment