Commit 3839d224 authored by Julien Muchembled's avatar Julien Muchembled

tweak: do not crash when trying to remove all nodes

parent 8a645d9f
...@@ -197,9 +197,14 @@ class AdministrationHandler(MasterHandler): ...@@ -197,9 +197,14 @@ class AdministrationHandler(MasterHandler):
@__change_pt_rpc @__change_pt_rpc
def tweakPartitionTable(self, conn, uuid_list): def tweakPartitionTable(self, conn, uuid_list):
app = self.app app = self.app
app.broadcastPartitionChanges(app.pt.tweak([node drop_list = [node for node in app.nm.getStorageList()
for node in app.nm.getStorageList() if node.getUUID() in uuid_list or not node.isRunning()]
if node.getUUID() in uuid_list or not node.isRunning()])) try:
changed_list = app.pt.tweak(drop_list)
except PartitionTableException, e:
raise AnswerDenied(str(e))
else:
app.broadcastPartitionChanges(changed_list)
conn.answer(Errors.Ack('')) conn.answer(Errors.Ack(''))
@check_state(ClusterStates.RUNNING) @check_state(ClusterStates.RUNNING)
......
...@@ -230,6 +230,8 @@ class PartitionTable(neo.lib.pt.PartitionTable): ...@@ -230,6 +230,8 @@ class PartitionTable(neo.lib.pt.PartitionTable):
# Collect some data in a usable form for the rest of the method. # Collect some data in a usable form for the rest of the method.
node_list = {node: {} for node in self.count_dict node_list = {node: {} for node in self.count_dict
if node not in drop_list} if node not in drop_list}
if not node_list:
raise neo.lib.pt.PartitionTableException("Can't remove all nodes.")
drop_list = defaultdict(list) drop_list = defaultdict(list)
for offset, row in enumerate(self.partition_list): for offset, row in enumerate(self.partition_list):
for cell in row: for cell in row:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment