Skip to content

Commit

Permalink
[FIX] packaging: wait for windows sshd service
Browse files Browse the repository at this point in the history
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#58271

Signed-off-by: Christophe Monniez (moc) <[email protected]>
  • Loading branch information
d-fence committed Sep 24, 2020
1 parent b22a8e5 commit aed85d8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions setup/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ def start(self):
]
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)
Expand All @@ -413,6 +413,8 @@ def ssh(self, cmd):
'ssh',
'-o', 'UserKnownHostsFile=/dev/null',
'-o', 'StrictHostKeyChecking=no',
'-o', 'BatchMode=yes',
'-o', 'ConnectTimeout=10',
'-p', '10022',
'-i', self.ssh_key,
'%[email protected]' % self.login,
Expand All @@ -429,6 +431,15 @@ def rsync(self, rsync_args, options=['--delete', '--exclude', '.git', '--exclude
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

Expand Down

0 comments on commit aed85d8

Please sign in to comment.