From 60efa07689a886a56360c078976cc7ea7704340d Mon Sep 17 00:00:00 2001 From: Andrea Waltlova Date: Mon, 1 Jul 2024 12:17:23 +0200 Subject: [PATCH] Don't reboot system if upgrade successfull Signed-off-by: Andrea Waltlova --- playbooks/leapp-upgrade.yml | 32 ++++++++++++++++---------------- scripts/leapp_script.py | 7 ++++--- tests/test_main.py | 3 ++- tests/test_parse_results.py | 2 +- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/playbooks/leapp-upgrade.yml b/playbooks/leapp-upgrade.yml index 74d5eb2..cf4735d 100644 --- a/playbooks/leapp-upgrade.yml +++ b/playbooks/leapp-upgrade.yml @@ -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 @@ -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: diff --git a/scripts/leapp_script.py b/scripts/leapp_script.py index c223d05..9fe7002 100644 --- a/scripts/leapp_script.py +++ b/scripts/leapp_script.py @@ -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 @@ -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( diff --git a/tests/test_main.py b/tests/test_main.py index 7672b7a..6994fb5 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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() diff --git a/tests/test_parse_results.py b/tests/test_parse_results.py index 0d70798..a414f66 100644 --- a/tests/test_parse_results.py +++ b/tests/test_parse_results.py @@ -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." )