mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 21:08:51 +00:00
LinuxDevice: fixed reboot.
- Deal with the dropped connection on issuing "reboot" - Introduced a fixed initial delay before polling for connection to avoid re-connecting to adevice that is still in the process of shutting down.
This commit is contained in:
parent
de133cddb4
commit
203a3f7d07
@ -632,7 +632,11 @@ class LinuxDevice(BaseLinuxDevice):
|
|||||||
# Power control
|
# Power control
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.execute('reboot', as_root=True)
|
try:
|
||||||
|
self.execute('reboot', as_root=True)
|
||||||
|
except DeviceError as e:
|
||||||
|
if 'Connection dropped' not in e.message:
|
||||||
|
raise e
|
||||||
self._is_ready = False
|
self._is_ready = False
|
||||||
|
|
||||||
def hard_reset(self):
|
def hard_reset(self):
|
||||||
@ -644,8 +648,15 @@ class LinuxDevice(BaseLinuxDevice):
|
|||||||
else:
|
else:
|
||||||
self.reset()
|
self.reset()
|
||||||
self.logger.debug('Waiting for device...')
|
self.logger.debug('Waiting for device...')
|
||||||
|
# Wait a fixed delay before starting polling to give the device time to
|
||||||
|
# shut down, otherwise, might create the connection while it's still shutting
|
||||||
|
# down resulting in subsequenct connection failing.
|
||||||
|
initial_delay = 20
|
||||||
|
time.sleep(initial_delay)
|
||||||
|
boot_timeout = max(self.boot_timeout - initial_delay, 10)
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
while (time.time() - start_time) < self.boot_timeout:
|
while (time.time() - start_time) < boot_timeout:
|
||||||
try:
|
try:
|
||||||
s = socket.create_connection((self.host, self.port), timeout=5)
|
s = socket.create_connection((self.host, self.port), timeout=5)
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -172,9 +172,8 @@ class SshShell(object):
|
|||||||
logger.warning('Could not get exit code for "{}",\ngot: "{}"'.format(command, exit_code_text))
|
logger.warning('Could not get exit code for "{}",\ngot: "{}"'.format(command, exit_code_text))
|
||||||
return output
|
return output
|
||||||
except EOF:
|
except EOF:
|
||||||
logger.error('Dropped connection detected.')
|
|
||||||
self.connection_lost = True
|
self.connection_lost = True
|
||||||
raise
|
raise DeviceError('Connection dropped.')
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
logger.debug('Logging out {}@{}'.format(self.username, self.host))
|
logger.debug('Logging out {}@{}'.format(self.username, self.host))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user