Commit 3839d224 by Julien Muchembled

tweak: do not crash when trying to remove all nodes

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