Commit 5738af5f 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 60d6b4fb
...@@ -234,18 +234,31 @@ class SlapOSControler(object): ...@@ -234,18 +234,31 @@ 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
time.sleep(20)
try:
slap = self.slap = slapos.slap.slap() slap = self.slap = slapos.slap.slap()
# Wait for proxy to accept connections
retries = 0
while True:
time.sleep(.5)
try:
slap.initializeConnection(config['master_url']) 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
try:
# 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