@@ -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 ("\n Performing 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
0 commit comments