diff options
author | Ondra Machacek <omachace@redhat.com> | 2017-10-25 11:55:47 +0200 |
---|---|---|
committer | Ryan S. Brown <sb@ryansb.com> | 2017-11-02 14:40:31 -0400 |
commit | dd930344b64c3f5b4b5a1fd11d8b13a524eee963 (patch) | |
tree | 80308e9abf56bad8f76a2ac39e116cbe87df59e3 | |
parent | 3df921a14aa229ae6cebc8591c351bc4c2e260a7 (diff) | |
download | ansible-dd930344b64c3f5b4b5a1fd11d8b13a524eee963.tar.gz |
ovirt_hosts: Don't fail upgrade when NON_RESPONSIVE state
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/ansible/modules/cloud/ovirt/ovirt_hosts.py | 28 |
2 files changed, 27 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index be4be0f441..b6678611d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,8 @@ Ansible Changes By Release (https://github.com/ansible/ansible/pull/31973) * Fix fencing and kuma usage in ovirt_cluster module (https://github.com/ansible/ansible/pull/32190) +* Fix failure during upgrade due to NON_RESPONSIVE state for ovirt_hosts module + (https://github.com/ansible/ansible/pull/32192) <a id="2.4.1"></a> diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py index 903e576436..0c3680e1c4 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py @@ -317,6 +317,28 @@ class HostsModule(BaseModule): 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 [ @@ -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( @@ -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']) @@ -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, |