From 31d255156699b9ab89cbbd1b36a7cc7c63f00284 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9gory=20Wisniewski?= <gregory@nexedi.com>
Date: Thu, 6 Aug 2009 14:47:58 +0000
Subject: [PATCH] When changing a node state, broadcast those changes after the
 partition table changes because if the node have to be dropped (set in DOWN
 state), the partition table update will contains it's UUID after it was
 removed from the storages partition table and they will fails to find the
 related node.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1229 71dcc9de-d417-0410-9af5-da40c76e7ee4
---
 neo/master/handlers/administration.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/neo/master/handlers/administration.py b/neo/master/handlers/administration.py
index 221e526a..59005c8a 100644
--- a/neo/master/handlers/administration.py
+++ b/neo/master/handlers/administration.py
@@ -87,16 +87,6 @@ class AdministrationHandler(MasterHandler):
                 conn.notify(p)
                 return
 
-            node.setState(state)
-            p = protocol.noError('state changed')
-            conn.answer(p, packet.getId())
-            app.broadcastNodeInformation(node)
-            # If this is a storage node, ask it to start.
-            if node.isStorage() and state == RUNNING_STATE  \
-                   and self.app.cluster_state == RUNNING:
-                logging.info("asking sn to start operation")
-                node_conn.notify(protocol.startOperation())
-
         # modify the partition table if required
         if modify_partition_table and node.isStorage():
             if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, HIDDEN_STATE):
@@ -115,6 +105,17 @@ class AdministrationHandler(MasterHandler):
                 ptid = app.pt.setNextID()
                 app.broadcastPartitionChanges(ptid, cell_list)
 
+        if node.getState() != state:
+            node.setState(state)
+            p = protocol.noError('state changed')
+            conn.answer(p, packet.getId())
+            app.broadcastNodeInformation(node)
+            # If this is a storage node, ask it to start.
+            if node.isStorage() and state == RUNNING_STATE  \
+                   and self.app.cluster_state == RUNNING:
+                logging.info("asking sn to start operation")
+                node_conn.notify(protocol.startOperation())
+
     def handleAddPendingNodes(self, conn, packet, uuid_list):
         uuids = ', '.join([dump(uuid) for uuid in uuid_list])
         logging.debug('Add nodes %s' % uuids)
-- 
2.30.9