Skip to content

Commit 48453da

Browse files
committed
Revert "PR feedback explanation"
This reverts commit f9ae07e.
1 parent f9ae07e commit 48453da

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

src/core/src/CoreMain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ def __init__(self, argv):
9393
# setting current operation here, to include patch_installer init within installation actions, ensuring any exceptions during patch_installer init are added in installation summary errors object
9494
status_handler.set_current_operation(Constants.INSTALLATION)
9595
patch_installer = container.get('patch_installer')
96-
patch_installation_successful, maintenance_window_exceeded = patch_installer.start_installation()
96+
patch_installation_successful = patch_installer.start_installation()
9797
patch_assessment_successful = False
9898
patch_assessment_successful = patch_assessor.start_assessment()
9999

100100
# PatchInstallationSummary to be marked as completed successfully only after the implicit (i.e. 2nd) assessment is completed, as per CRP's restrictions
101101
if patch_assessment_successful and patch_installation_successful:
102102
patch_installer.mark_installation_completed()
103103
overall_patch_installation_operation_successful = True
104-
elif patch_installer.should_patch_installation_status_be_set_to_warning(patch_installation_successful, maintenance_window_exceeded):
104+
elif patch_installer.set_patch_installation_status_to_warning_from_failed():
105105
patch_installer.mark_installation_completed_with_warning()
106106
overall_patch_installation_operation_successful = True
107107
self.update_patch_substatus_if_pending(patch_operation_requested, overall_patch_installation_operation_successful, patch_assessment_successful, configure_patching_successful, status_handler, composite_logger)

src/core/src/core_logic/PatchInstaller.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ
5353

5454
self.stopwatch = Stopwatch(self.env_layer, self.telemetry_writer, self.composite_logger)
5555

56+
self.__enable_installation_status_to_warning_flag = False
57+
5658
def start_installation(self, simulate=False):
5759
""" Kick off a patch installation run """
5860
self.status_handler.set_current_operation(Constants.INSTALLATION)
@@ -124,7 +126,7 @@ def start_installation(self, simulate=False):
124126
overall_patch_installation_successful = bool(update_run_successful and not maintenance_window_exceeded)
125127
# NOTE: Not updating installation substatus at this point because we need to wait for the implicit/second assessment to complete first, as per CRP's instructions
126128

127-
return overall_patch_installation_successful, maintenance_window_exceeded
129+
return overall_patch_installation_successful
128130

129131
def write_installer_perf_logs(self, patch_operation_successful, installed_patch_count, retry_count, maintenance_window, maintenance_window_exceeded, task_status, error_msg):
130132
perc_maintenance_window_used = -1
@@ -282,7 +284,7 @@ def install_updates(self, maintenance_window, package_manager, simulate=False):
282284
successful_parent_package_install_count_in_batch_patching = self.successful_parent_package_install_count
283285

284286
if len(packages) == 0:
285-
self.log_final_metrics(maintenance_window, patch_installation_successful, maintenance_window_exceeded, installed_update_count)
287+
self.log_final_installation_metric(patch_installation_successful, maintenance_window_exceeded, maintenance_window, installed_update_count)
286288
return installed_update_count, patch_installation_successful, maintenance_window_exceeded
287289
else:
288290
progress_status = self.progress_template.format(str(datetime.timedelta(minutes=maintenance_window.get_remaining_time_in_minutes())), str(self.attempted_parent_package_install_count), str(self.successful_parent_package_install_count), str(self.failed_parent_package_install_count), str(installed_update_count - self.successful_parent_package_install_count),
@@ -381,7 +383,7 @@ def install_updates(self, maintenance_window, package_manager, simulate=False):
381383
self.composite_logger.log_debug("\nPerforming final system state reconciliation...")
382384
installed_update_count += self.perform_status_reconciliation_conditionally(package_manager, True)
383385

384-
self.log_final_metrics(maintenance_window, patch_installation_successful, maintenance_window_exceeded, installed_update_count)
386+
self.log_final_installation_metric(patch_installation_successful, maintenance_window_exceeded, maintenance_window, installed_update_count)
385387

386388
install_update_count_in_sequential_patching = installed_update_count - install_update_count_in_batch_patching
387389
attempted_parent_package_install_count_in_sequential_patching = self.attempted_parent_package_install_count - attempted_parent_package_install_count_in_batch_patching
@@ -418,6 +420,7 @@ def log_final_metrics(self, maintenance_window, patch_installation_successful, m
418420

419421
def log_final_warning_metric(self, maintenance_window, installed_update_count):
420422
""" Log the final metrics for warning installation status. """
423+
421424
self.__log_progress_status(maintenance_window, installed_update_count)
422425
message = "All requested package(s) are installed. Any patch errors marked are from previous attempts."
423426
self.status_handler.add_error_to_status(message, Constants.PatchOperationErrorCodes.PACKAGES_RETRY_SUCCEEDED)
@@ -689,12 +692,9 @@ def mark_installation_completed(self):
689692

690693
def mark_installation_completed_with_warning(self):
691694
""" Marks Installation operation as warning by updating the status of PatchInstallationSummary as warning and patch metadata to be sent to healthstore.
692-
This is set outside of start_installation function due to a restriction in CRP, where installation substatus should be marked as warning only after the implicit (2nd) assessment operation
693-
and all customer requested packages are installed. """
695+
This is set outside of start_installation function to a restriction in CRP, where installation substatus should be marked as warning only after the implicit (2nd) assessment operation
696+
and all supposed packages are installed as expected. """
694697

695-
message = "All requested package(s) are installed. Any patch errors marked are from previous attempts."
696-
self.composite_logger.log_error(message)
697-
self.status_handler.add_error_to_status(message, Constants.PatchOperationErrorCodes.PACKAGES_RETRY_SUCCEEDED)
698698
self.status_handler.set_installation_substatus_json(status=Constants.STATUS_WARNING)
699699

700700
# Update patch metadata in status for auto patching request, to be reported to healthStore
@@ -812,11 +812,7 @@ def get_max_batch_size(self, maintenance_window, package_manager):
812812
return max_batch_size_for_packages
813813

814814
def __log_progress_status(self, maintenance_window, installed_update_count):
815-
progress_status = self.progress_template.format(str(datetime.timedelta(minutes=maintenance_window.get_remaining_time_in_minutes())),
816-
str(self.attempted_parent_package_install_count),
817-
str(self.successful_parent_package_install_count),
818-
str(self.failed_parent_package_install_count),
819-
str(installed_update_count - self.successful_parent_package_install_count),
815+
progress_status = self.progress_template.format(str(datetime.timedelta(minutes=maintenance_window.get_remaining_time_in_minutes())), str(self.attempted_parent_package_install_count), str(self.successful_parent_package_install_count), str(self.failed_parent_package_install_count), str(installed_update_count - self.successful_parent_package_install_count),
820816
"Completed processing packages!")
821817
self.composite_logger.log(progress_status)
822818

@@ -828,5 +824,22 @@ def __send_metadata_to_health_store(self):
828824
report_to_healthstore=True,
829825
wait_after_update=False)
830826

831-
def should_patch_installation_status_be_set_to_warning(self, patch_installation_successful, maintenance_window_exceeded):
832-
return not patch_installation_successful and not maintenance_window_exceeded and self.status_handler.are_all_requested_packgaes_installed()
827+
# region - Failed packages retry succeeded
828+
def log_final_installation_metric(self, patch_installation_successful, maintenance_window_exceeded, maintenance_window, installed_update_count):
829+
""" log final installation operation status. """
830+
warning_status = self.__check_installation_status_can_set_to_warning(patch_installation_successful, maintenance_window_exceeded)
831+
if warning_status:
832+
self.log_final_warning_metric(maintenance_window, installed_update_count)
833+
else:
834+
self.log_final_metrics(maintenance_window, patch_installation_successful, maintenance_window_exceeded, installed_update_count)
835+
836+
def __check_installation_status_can_set_to_warning(self, patch_installation_successful, maintenance_window_exceeded):
837+
""" Verify patch installation status can be set to warning from failed. """
838+
# type (bool, bool) -> bool
839+
self.__enable_installation_status_to_warning_flag = not patch_installation_successful and not maintenance_window_exceeded and self.status_handler.check_all_requested_packages_install_state()
840+
return self.__enable_installation_status_to_warning_flag
841+
842+
def set_patch_installation_status_to_warning_from_failed(self):
843+
"""Access enable_installation_warning_status value"""
844+
return self.__enable_installation_status_to_warning_flag
845+
# endregion

src/core/src/service_interfaces/StatusHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def get_os_name_and_version(self):
263263
self.composite_logger.log_error("Unable to determine platform information: {0}".format(repr(error)))
264264
return "unknownDist_unknownVer"
265265

266-
def are_all_requested_packgaes_installed(self):
266+
def check_all_requested_packages_install_state(self):
267267
# type (none) -> bool
268268
""" Check if all requested package(s) are installed. """
269269

src/core/tests/Test_PatchInstaller.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ def test_patch_installer_for_azgps_coordinated(self):
241241
argument_composer.maximum_duration = "PT30M"
242242
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.APT)
243243
runtime.set_legacy_test_type('HappyPath')
244-
patch_installation_successful, maintenance_window_exceeded = runtime.patch_installer.start_installation()
245-
self.assertFalse(patch_installation_successful) # failure is in unrelated patch installation batch processing
244+
self.assertFalse(runtime.patch_installer.start_installation()) # failure is in unrelated patch installation batch processing
246245
self.assertEqual(runtime.execution_config.max_patch_publish_date, "20240401T000000Z")
247246
self.assertEqual(runtime.package_manager.max_patch_publish_date, "") # reason: not enough time to use
248247

@@ -254,24 +253,21 @@ def test_patch_installer_for_azgps_coordinated(self):
254253
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.APT)
255254
runtime.set_legacy_test_type('HappyPath')
256255
runtime.package_manager.install_security_updates_azgps_coordinated = lambda: (1, "Failed")
257-
patch_installation_successful, maintenance_window_exceeded = runtime.patch_installer.start_installation()
258-
self.assertFalse(patch_installation_successful)
256+
self.assertFalse(runtime.patch_installer.start_installation())
259257
self.assertEqual(runtime.execution_config.max_patch_publish_date, "20240401T000000Z")
260258
self.assertEqual(runtime.package_manager.max_patch_publish_date, "") # reason: the strict SDP is forced to fail with the lambda above
261259
runtime.stop()
262260

263261
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.YUM)
264262
runtime.set_legacy_test_type('HappyPath')
265-
patch_installation_successful, maintenance_window_exceeded = runtime.patch_installer.start_installation()
266-
self.assertTrue(patch_installation_successful)
263+
self.assertTrue(runtime.patch_installer.start_installation())
267264
self.assertEqual(runtime.execution_config.max_patch_publish_date, "20240401T000000Z")
268265
self.assertEqual(runtime.package_manager.max_patch_publish_date, "") # unsupported in Yum
269266
runtime.stop()
270267

271268
runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.ZYPPER)
272269
runtime.set_legacy_test_type('HappyPath')
273-
patch_installation_successful, maintenance_window_exceeded = runtime.patch_installer.start_installation()
274-
self.assertFalse(patch_installation_successful) # failure is in unrelated patch installation batch processing
270+
self.assertFalse(runtime.patch_installer.start_installation()) # failure is in unrelated patch installation batch processing
275271
self.assertEqual(runtime.execution_config.max_patch_publish_date, "20240401T000000Z")
276272
self.assertEqual(runtime.package_manager.max_patch_publish_date, "") # unsupported in Zypper
277273
runtime.stop()

0 commit comments

Comments
 (0)