Skip to content
Snippets Groups Projects
Commit aed85d89 authored by Christophe Monniez's avatar Christophe Monniez
Browse files

[FIX] packaging: wait for windows sshd service


In some undeterministic conditions, the Windows virtual machine can take
more than 60 sec to start and have the sshd service ready.

With this commit, the packaging script tries to connect to the VM up to
30 times, giving more than 10 minutes for the boot.

As soon as the connexion is ready, the packaging starts. This means
that the script will probably start sooner in most of the cases.

closes odoo/odoo#58271

Signed-off-by: default avatarChristophe Monniez (moc) <moc@odoo.com>
parent b22a8e50
Branches
Tags
No related merge requests found
......@@ -398,10 +398,10 @@ class KVM(object):
]
logging.info("Starting kvm: {}".format(" ".join(kvm_cmd)))
self.kvm_proc = subprocess.Popen(kvm_cmd)
time.sleep(60) # give some time to the VM to start, otherwise the SSH server may not be ready
signal.alarm(2400)
signal.signal(signal.SIGALRM, self.timeout)
try:
self.wait_ssh(30) # give some time to the VM to start, otherwise the SSH server may not be ready
signal.alarm(2400)
signal.signal(signal.SIGALRM, self.timeout)
self.run()
finally:
signal.signal(signal.SIGALRM, signal.SIG_DFL)
......@@ -413,6 +413,8 @@ class KVM(object):
'ssh',
'-o', 'UserKnownHostsFile=/dev/null',
'-o', 'StrictHostKeyChecking=no',
'-o', 'BatchMode=yes',
'-o', 'ConnectTimeout=10',
'-p', '10022',
'-i', self.ssh_key,
'%s@127.0.0.1' % self.login,
......@@ -429,6 +431,15 @@ class KVM(object):
cmd.extend(rsync_args)
run_cmd(cmd).check_returncode()
def wait_ssh(self, n):
for i in range(n):
try:
self.ssh('exit')
return
except subprocess.CalledProcessError:
time.sleep(10)
raise Exception('Unable to conncect to the VM')
def run(self):
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment