From 0779e3aae2c366cc00bee228175b772750906591 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sun, 23 Nov 2008 15:35:02 +0000
Subject: [PATCH] Only update ssconf on cluster serial change

There is no need to update ssconf if the cluster serial number has not
changed.

Reviewed-by: ultrotter
---
 lib/config.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/config.py b/lib/config.py
index 0d1d89739..f0457f26b 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -802,6 +802,9 @@ class ConfigWriter:
       raise errors.ConfigurationError("Incomplete configuration"
                                       " (missing cluster.rsahostkeypub)")
     self._config_data = data
+    # init the last serial as -1 so that the next write will cause
+    # ssconf update
+    self._last_cluster_serial = -1
 
   def _DistributeConfig(self):
     """Distribute the configuration to the other nodes.
@@ -860,7 +863,9 @@ class ConfigWriter:
     self._DistributeConfig()
 
     # Write ssconf files on all nodes (including locally)
-    rpc.RpcRunner.call_write_ssconf_files(self._UnlockedGetNodeList())
+    if self._last_cluster_serial < self._config_data.cluster.serial_no:
+      rpc.RpcRunner.call_write_ssconf_files(self._UnlockedGetNodeList())
+      self._last_cluster_serial = self._config_data.cluster.serial_no
 
   @locking.ssynchronized(_config_lock)
   def InitConfig(self, version, cluster_config, master_node_config):
-- 
GitLab