Don't listen twice in parallel, this seems doomed to failure; we only ever switch HVs by changing the state too

This commit is contained in:
Joshua Boniface 2018-06-11 21:35:37 -04:00
parent 202b8f41af
commit 78e61a759e
1 changed files with 9 additions and 11 deletions

View File

@ -39,25 +39,23 @@ class VMInstance:
self.inshutdown = False self.inshutdown = False
self.inmigrate = False self.inmigrate = False
self.inreceive = False self.inreceive = False
self.ininit = True
self.dom = self.lookupByUUID(self.domuuid) self.dom = self.lookupByUUID(self.domuuid)
# Watch for changes to the state field in Zookeeper # Watch for changes to the state field in Zookeeper
@zk.DataWatch('/domains/{}/state'.format(self.domuuid)) @zk.DataWatch('/domains/{}/state'.format(self.domuuid))
def watch_state(data, stat, event=""): def watch_state(data, stat, event=""):
if self.ininit == False: self.manage_vm_state()
self.manage_vm_state()
# Watch for changes to the hypervisor field in Zookeeper # Watch for changes to the hypervisor field in Zookeeper
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid)) # @zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
def watch_hypervisor(data, stat, event=""): # def watch_hypervisor(data, stat, event=""):
if self.ininit == False: # if self.ininit == False:
self.manage_vm_state() # self.manage_vm_state()
else: # else:
# This case handles the very first init at startup to avoid it happening twice # # This case handles the very first init at startup to avoid it happening twice
self.ininit = False # self.ininit = False
self.manage_vm_state() # self.manage_vm_state()
# Get data functions # Get data functions
def getstate(self): def getstate(self):