From 7f3caa28591d9207108eb9e134f82ac0e2276119 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 17 Jul 2018 14:29:18 -0400 Subject: [PATCH] Explicitly copy domain_list array Fixes a bug caused by looping over a changing list of domains during the flush (and unflush) actions. Fixes #7 --- pvcd/NodeInstance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pvcd/NodeInstance.py b/pvcd/NodeInstance.py index 3ee0453e..194bda26 100644 --- a/pvcd/NodeInstance.py +++ b/pvcd/NodeInstance.py @@ -129,7 +129,10 @@ class NodeInstance(): self.inflush = True ansiiprint.echo('Flushing node "{}" of running VMs'.format(self.name), '', 'i') ansiiprint.echo('Domain list: {}'.format(', '.join(self.domain_list)), '', 'c') - for dom_uuid in self.domain_list: + fixed_domain_list = self.domain_list.copy() + for dom_uuid in fixed_domain_list: + ansiiprint.echo('Selecting target to migrate VM "{}"'.format(dom_uuid), '', 'i') + most_memfree = 0 target_hypervisor = None hypervisor_list = zkhandler.listchildren(self.zk_conn, '/nodes') @@ -177,7 +180,8 @@ class NodeInstance(): self.inflush = True ansiiprint.echo('Restoring node {} to active service.'.format(self.name), '', 'i') zkhandler.writedata(self.zk_conn, { '/nodes/{}/domainstate'.format(self.name): 'ready' }) - for dom_uuid in self.s_domain: + fixed_domain_list = self.s_domain.copy() + for dom_uuid in fixed_domain_list: try: last_hypervisor = zkhandler.readdata(self.zk_conn, '/domains/{}/lasthypervisor'.format(dom_uuid)) except: