Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovirt_hosts: Don't fail upgrade when NON_RESPONSIVE state #32123

Merged
merged 1 commit into from
Oct 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions lib/ansible/modules/cloud/ovirt/ovirt_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,28 @@ def post_reinstall(self, host):
timeout=self.param('timeout'),
)

def failed_state_after_reinstall(self, host, count=0):
if host.status in [
hoststate.ERROR,
hoststate.INSTALL_FAILED,
hoststate.NON_OPERATIONAL,
]:
return True

# If host is in non-responsive state after upgrade/install
# let's wait for few seconds and re-check again the state:
if host.status == hoststate.NON_RESPONSIVE:
if count <= 3:
time.sleep(20)
return self.failed_state_after_reinstall(
self._service.service(host.id).get(),
count + 1,
)
else:
return True

return False


def failed_state(host):
return host.status in [
Expand Down Expand Up @@ -421,7 +443,7 @@ def main():
module.params.get('hosted_engine') == 'deploy'
) if module.params.get('hosted_engine') is not None else None,
result_state=hoststate.UP if host is None else None,
fail_condition=failed_state if host is None else lambda h: False,
fail_condition=hosts_module.failed_state_after_reinstall if host is None else lambda h: False,
)
if module.params['activate'] and host is not None:
ret = hosts_module.action(
Expand Down Expand Up @@ -473,7 +495,7 @@ def main():
action_condition=lambda h: h.update_available,
wait_condition=lambda h: h.status == result_state,
post_action=lambda h: time.sleep(module.params['poll_interval']),
fail_condition=failed_state,
fail_condition=hosts_module.failed_state_after_reinstall,
)
elif state == 'iscsidiscover':
host_id = get_id_by_name(hosts_service, module.params['name'])
Expand Down Expand Up @@ -546,7 +568,7 @@ def main():
action_condition=lambda h: h.status == hoststate.MAINTENANCE,
post_action=hosts_module.post_reinstall,
wait_condition=lambda h: h.status == hoststate.MAINTENANCE,
fail_condition=failed_state,
fail_condition=hosts_module.failed_state_after_reinstall,
host=otypes.Host(
override_iptables=module.params['override_iptables'],
) if module.params['override_iptables'] else None,
Expand Down