Add some tweaks to prevent clobbering state changes happening at startup and during each keepalive cycle
This commit is contained in:
parent
f4493ed7c1
commit
5ad49d239e
|
@ -198,10 +198,12 @@ class NodeInstance():
|
|||
else:
|
||||
self.daemon_state = 'start'
|
||||
|
||||
# Toggle state management of all VMs and remove any non-running VMs
|
||||
# Toggle state management of dead VMs
|
||||
for domain, instance in self.s_domain.items():
|
||||
if instance.inshutdown == False and domain in self.domain_list:
|
||||
instance.manage_vm_state()
|
||||
if instance.getstate() == 'start' and instance.gethypervisor() == self.name and instance.dom == None:
|
||||
instance.manage_vm_state()
|
||||
|
||||
if instance.dom == None:
|
||||
try:
|
||||
self.domain_list.remove(domain)
|
||||
|
@ -218,6 +220,8 @@ class NodeInstance():
|
|||
self.domain_list.remove(domain)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
instance.setnoclobber()
|
||||
|
||||
# toggle state management of this node
|
||||
if self.domain_state == 'flush':
|
||||
|
|
|
@ -40,17 +40,24 @@ class VMInstance:
|
|||
self.inmigrate = False
|
||||
self.inreceive = False
|
||||
|
||||
self.dom = self.lookupByUUID(self.domuuid)
|
||||
# These stop a weird clobber at startup
|
||||
self.noclobber = False
|
||||
|
||||
# Watch for changes to the hypervisor field in Zookeeper
|
||||
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
|
||||
def watch_hypervisor(data, stat, event=""):
|
||||
self.manage_vm_state()
|
||||
self.dom = self.lookupByUUID(self.domuuid)
|
||||
|
||||
# Watch for changes to the state field in Zookeeper
|
||||
@zk.DataWatch('/domains/{}/state'.format(self.domuuid))
|
||||
def watch_state(data, stat, event=""):
|
||||
self.manage_vm_state()
|
||||
if self.noclobber == False:
|
||||
self.noclobber = True
|
||||
self.manage_vm_state()
|
||||
|
||||
# Watch for changes to the hypervisor field in Zookeeper
|
||||
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
|
||||
def watch_hypervisor(data, stat, event=""):
|
||||
if self.noclobber == False:
|
||||
self.noclobber = True
|
||||
self.manage_vm_state()
|
||||
|
||||
# Get data functions
|
||||
def getstate(self):
|
||||
|
@ -59,6 +66,10 @@ class VMInstance:
|
|||
def gethypervisor(self):
|
||||
return self.hypervisor
|
||||
|
||||
# Allow the node to set the noclobber status once it performs its first keepalive
|
||||
def setnoclobber(self):
|
||||
self.noclobber = False
|
||||
|
||||
# Start up the VM
|
||||
def start_vm(self, xmlconfig):
|
||||
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')
|
||||
|
@ -286,7 +297,6 @@ class VMInstance:
|
|||
domxml = str(domxml.decode('ascii'))
|
||||
self.start_vm(domxml)
|
||||
|
||||
|
||||
# This function is a wrapper for libvirt.lookupByUUID which fixes some problems
|
||||
# 1. Takes a text UUID and handles converting it to bytes
|
||||
# 2. Try's it and returns a sensible value if not
|
||||
|
|
Loading…
Reference in New Issue