Commit 7294b6b1 authored by Jérome Perrin's avatar Jérome Perrin Committed by Klaus Wölfel

testnode: wait for proxy to accept connections

Instead of sleeping, try using an API method until it stops raising
ConnectionError.

/reviewed-on nexedi/erp5!650
parent a21bc409
...@@ -234,18 +234,32 @@ class SlapOSControler(object): ...@@ -234,18 +234,32 @@ class SlapOSControler(object):
proxy = subprocess.Popen([config['slapos_binary'], proxy = subprocess.Popen([config['slapos_binary'],
'proxy', 'start', '--cfg' , self.slapos_config], **kwargs) 'proxy', 'start', '--cfg' , self.slapos_config], **kwargs)
process_manager.process_pid_set.add(proxy.pid) process_manager.process_pid_set.add(proxy.pid)
# XXX: dirty, giving some time for proxy to being able to accept
# connections slap = self.slap = slapos.slap.slap()
time.sleep(10) # Wait for proxy to accept connections
retries = 0
while True:
time.sleep(.5)
try:
slap.initializeConnection(config['master_url'])
computer = slap.registerComputer(config['computer_id'])
# Call a method to ensure connection to master can be established
computer.getComputerPartitionList()
except slapos.slap.ConnectionError, e:
retries += 1
if retries >= 20:
raise
logger.debug("Proxy still not started %s, retrying", e)
else:
break
>>>>>>> 5738af5f6a... testnode: wait for proxy to accept connections
try: try:
slap = self.slap = slapos.slap.slap()
slap.initializeConnection(config['master_url'])
# register software profile # register software profile
for path in self.software_path_list: for path in self.software_path_list:
slap.registerSupply().supply( slap.registerSupply().supply(
path, path,
computer_guid=config['computer_id']) computer_guid=config['computer_id'])
computer = slap.registerComputer(config['computer_id'])
except Exception: except Exception:
logger.exception("SlapOSControler.initializeSlapOSControler") logger.exception("SlapOSControler.initializeSlapOSControler")
raise ValueError("Unable to registerSupply") raise ValueError("Unable to registerSupply")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment