[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#58417 X-original-commit: aed85d89f958377f44e150c30a44f28e281dcb79 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
This commit is contained in:
+14
-3
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user