Skip to content

Commit

Permalink
Wait for host to be in result state (#621)
Browse files Browse the repository at this point in the history
* Wait for host to be in result state

Bug introduced in #580.
The update_available is false just after the upgrade, and
HOST_UPGRADE_FINISHED_AND_WILL_BE_REBOOTED is logged. But the host is
not yet rebooted, so we still need to wait for the status to be UP or
MAINTENANCE.

Signed-off-by: Martin Nečas <necas.marty@gmail.com>

* Fix wait_condition on host upgrade

In #580 we introduced a check on update_available state of the host to
determine if the host upgrade finished when there were no updates
available for te host.

The downside of this is that when the update finishes, the
update_available flag is cleared, and ansible thinks the host upgrade is
complete and starts upgrading the next node. But the reboot is not
completed yet, so result_state != h.status.

The fix here is to save the update_available status before starting the
update. If there were no updates and status hasn't changed, then it goes
on. If there was an update on the other hand, it will wait for the
HOST_UPGRADE_FAILED / HOST_UPGRADE_FINISHED /
HOST_UPGRADE_FINISHED_AND_WILL_BE_REBOOTED events.

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Signed-off-by: Martin Nečas <necas.marty@gmail.com>

Signed-off-by: Martin Nečas <necas.marty@gmail.com>
Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Co-authored-by: Martin Nečas <necas.marty@gmail.com>
  • Loading branch information
2 people authored and mwperina committed Jan 24, 2023
1 parent a80c1d7 commit 4eca779
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/modules/ovirt_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,12 @@ def main():
)
# Set to False, because upgrade_check isn't 'changing' action:
hosts_module._changed = False

updates_available = host.update_available
ret = hosts_module.action(
action='upgrade',
action_condition=lambda h: h.update_available,
wait_condition=lambda h: not h.update_available or h.status == result_state and (
wait_condition=lambda h: h.status == result_state and ((
len([
event
for event in events_service.list(
Expand All @@ -625,7 +627,7 @@ def main():
search='type=842 or type=841 or type=888',
) if host.name in event.description
]) > 0
),
) or not updates_available),
post_action=lambda h: time.sleep(module.params['poll_interval']),
fail_condition=lambda h: hosts_module.failed_state_after_reinstall(h) or (
len([
Expand Down

0 comments on commit 4eca779

Please sign in to comment.