From 77db36a891ce6bcd6f9b1778ea2aa821cd02b04d Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 25 Dec 2019 21:02:46 -0500 Subject: [PATCH] Ensure migration out occurs --- node-daemon/pvcd/NodeInstance.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/node-daemon/pvcd/NodeInstance.py b/node-daemon/pvcd/NodeInstance.py index 4f8fa095..7045c4a6 100644 --- a/node-daemon/pvcd/NodeInstance.py +++ b/node-daemon/pvcd/NodeInstance.py @@ -119,18 +119,14 @@ class NodeInstance(object): if self.config['enable_networking']: if self.router_state == 'primary': self.logger.out('Setting node {} to primary state'.format(self.name), state='i') - #self.become_primary() transition_thread = threading.Thread(target=self.become_primary, args=(), kwargs={}) transition_thread.start() - #transition_thread.join() else: # Skip becoming secondary unless already running - if self.daemon_state == 'run': + if self.daemon_state == 'run' or self.daemon_state = 'shutdown': self.logger.out('Setting node {} to secondary state'.format(self.name), state='i') - #self.become_secondary() transition_thread = threading.Thread(target=self.become_secondary, args=(), kwargs={}) transition_thread.start() - #transition_thread.join() @self.zk_conn.DataWatch('/nodes/{}/domainstate'.format(self.name)) def watch_node_domainstate(data, stat, event=''): @@ -150,13 +146,12 @@ class NodeInstance(object): # toggle state management of this node if self.name == self.this_node: # Stop any existing flush jobs - if self.flush_thread: - self.flush_stopper = True + if self.flush_thread is not None: self.logger.out('Waiting for previous migration to complete'.format(self.name), state='i') + self.flush_stopper = True while self.flush_stopper: - time.sleep(1) - self.flush_stopper = False - self.flush_thread = None + time.sleep(0.1) + # Do flushing in a thread so it doesn't block the migrates out if self.domain_state == 'flush': self.flush_thread = threading.Thread(target=self.flush, args=(), kwargs={})