Skip to content

Commit

Permalink
Don't reboot system if upgrade successfull
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Waltlova <[email protected]>
  • Loading branch information
andywaltlova committed Jul 1, 2024
1 parent 9a75098 commit 60efa07
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
32 changes: 16 additions & 16 deletions playbooks/leapp-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
- name: Set message if leapp upgrade succeeded
set_fact:
message: >-
No problems found. The system will be upgraded. Rebooting system in 1 minute.
No problems found. Please reboot the system at your earliest convenience to continue with the upgrade process.
After reboot check inventory to verify the RHEL system is registered with new major version.
when: is_leapp_upgrade_successful is true

Expand All @@ -230,21 +230,21 @@
- name: Start insights-client for immediate data collection of leapp-report
ansible.builtin.shell: insights-client >/dev/null 2>&1

- name: Schedule reboot and Insights report if leapp upgrade is successful
block:
- name: Schedule insights-client after boot
file:
path: "/etc/insights-client/.run_insights_client_next_boot"
state: touch
- name: Enable boot service
systemd:
name: insights-client-boot.service
enabled: true
ignore_errors: true
- name: Schedule system reboot for 1 minute in the future
shell: shutdown -r +1 "Ansible triggered reboot"
ignore_errors: true
when: is_leapp_upgrade_successful is true
# - name: Schedule reboot and Insights report if leapp upgrade is successful
# block:
# - name: Schedule insights-client after boot
# file:
# path: "/etc/insights-client/.run_insights_client_next_boot"
# state: touch
# - name: Enable boot service
# systemd:
# name: insights-client-boot.service
# enabled: true
# ignore_errors: true
# - name: Schedule system reboot for 1 minute in the future
# shell: shutdown -r +1 "Ansible triggered reboot"
# ignore_errors: true
# when: is_leapp_upgrade_successful is true

- name: Print Task Result
ansible.builtin.debug:
Expand Down
7 changes: 4 additions & 3 deletions scripts/leapp_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ def parse_results(output, reboot_required=False):

if reboot_required:
message = (
"No problems found. System will be upgraded. Rebooting system in 1 minute. "
"No problems found. Please reboot the system at your earliest convenience "
"to continue with the upgrade process. "
"After reboot check inventory to verify the system is registered with new RHEL major version."
)
alert = inhibitor_count > 0 or error_count > 0
Expand Down Expand Up @@ -587,8 +588,8 @@ def main():
logger.info("Operation %s finished successfully.", SCRIPT_TYPE.title())

# NOTE: Leapp has --reboot option but we are not using it because we need to send update to Insights before reboot
if upgrade_reboot_required:
reboot_system()
# if upgrade_reboot_required:
# reboot_system()
except ProcessError as exception:
logger.error(exception.report)
output = OutputCollector(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def test_main_eligible_release_upgrade(
mock_execute_operation.assert_called_once()
mock_parse_results.assert_called_once()
mock_update_insights_inventory.assert_called_once()
mock_reboot_system.assert_called_once()
# NOTE: reboot_system is currently expected to not be called
mock_reboot_system.assert_not_called()
mock_setup_logger_handler.assert_called_once()
mock_setup_sos_report.assert_called_once()
mock_archive_old_logger_files.assert_called_once()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parse_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_gather_report_files_exist_with_reboot(
assert output.report_json.get("entries") == mock_entries
assert (
output.message
== "No problems found. System will be upgraded. Rebooting system in 1 minute. After reboot check inventory to verify the system is registered with new RHEL major version."
== "No problems found. Please reboot the system at your earliest convenience to continue with the upgrade process. After reboot check inventory to verify the system is registered with new RHEL major version."
)


Expand Down

0 comments on commit 60efa07

Please sign in to comment.