diff options
| author | Christophe Monniez <moc@odoo.com> | 2020-09-22 18:05:08 +0000 |
|---|---|---|
| committer | Christophe Monniez <moc@odoo.com> | 2020-09-24 10:32:31 +0000 |
| commit | aed85d89f958377f44e150c30a44f28e281dcb79 (patch) | |
| tree | 049b3d1f585317c8ed96b8dd23c6a59f322632b9 | |
| parent | b22a8e509c8760bbda1afd10d823f569ed1dcacd (diff) | |
[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: Christophe Monniez (moc) <moc@odoo.com>
| -rwxr-xr-x | setup/package.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/setup/package.py b/setup/package.py index b7c06fdf2cf..3bdc4b40f3f 100755 --- a/setup/package.py +++ b/setup/package.py @@ -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 |
