reboot - Fix connection timeout reset (#51000)

* only reset if we could retrieve the conn timeout
This commit is contained in:
Jordan Borean 2019-01-18 01:45:41 +10:00 committed by Sam Doran
parent c6d404cbe9
commit 9fa46e7f94
2 changed files with 19 additions and 11 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- reboot - Fix bug where the connection timeout was not reset in the same task after rebooting

View file

@ -296,7 +296,6 @@ class ActionModule(ActionBase):
try: try:
# keep on checking system boot_time with short connection responses # keep on checking system boot_time with short connection responses
reboot_timeout = int(self._task.args.get('reboot_timeout', self._task.args.get('reboot_timeout_sec', self.DEFAULT_REBOOT_TIMEOUT))) reboot_timeout = int(self._task.args.get('reboot_timeout', self._task.args.get('reboot_timeout_sec', self.DEFAULT_REBOOT_TIMEOUT)))
connect_timeout = self._task.args.get('connect_timeout', self._task.args.get('connect_timeout_sec', self.DEFAULT_CONNECT_TIMEOUT))
self.do_until_success_or_timeout( self.do_until_success_or_timeout(
action=self.check_boot_time, action=self.check_boot_time,
@ -305,16 +304,23 @@ class ActionModule(ActionBase):
distribution=distribution, distribution=distribution,
action_kwargs=action_kwargs) action_kwargs=action_kwargs)
if connect_timeout and original_connection_timeout: # Get the connect_timeout set on the connection to compare to the original
try: try:
display.debug("{action}: setting connect_timeout back to original value of {value}".format( connect_timeout = self._connection.get_option('connection_timeout')
action=self._task.action, except AnsibleError:
value=original_connection_timeout)) pass
self._connection.set_option("connection_timeout", original_connection_timeout) else:
self._connection.reset() if original_connection_timeout != connect_timeout:
except (AnsibleError, AttributeError) as e: try:
# reset the connection to clear the custom connection timeout display.debug("{action}: setting connect_timeout back to original value of {value}".format(
display.debug("{action}: failed to reset connection_timeout back to default: {error}".format(action=self._task.action, error=to_text(e))) action=self._task.action,
value=original_connection_timeout))
self._connection.set_option("connection_timeout", original_connection_timeout)
self._connection.reset()
except (AnsibleError, AttributeError) as e:
# reset the connection to clear the custom connection timeout
display.debug("{action}: failed to reset connection_timeout back to default: {error}".format(action=self._task.action,
error=to_text(e)))
# finally run test command to ensure everything is working # finally run test command to ensure everything is working
# FUTURE: add a stability check (system must remain up for N seconds) to deal with self-multi-reboot updates # FUTURE: add a stability check (system must remain up for N seconds) to deal with self-multi-reboot updates