@@ -53,8 +53,6 @@ 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-
5856 def start_installation (self , simulate = False ):
5957 """ Kick off a patch installation run """
6058 self .status_handler .set_current_operation (Constants .INSTALLATION )
@@ -126,7 +124,7 @@ def start_installation(self, simulate=False):
126124 overall_patch_installation_successful = bool (update_run_successful and not maintenance_window_exceeded )
127125 # 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
128126
129- return overall_patch_installation_successful
127+ return overall_patch_installation_successful , maintenance_window_exceeded
130128
131129 def write_installer_perf_logs (self , patch_operation_successful , installed_patch_count , retry_count , maintenance_window , maintenance_window_exceeded , task_status , error_msg ):
132130 perc_maintenance_window_used = - 1
@@ -284,7 +282,7 @@ def install_updates(self, maintenance_window, package_manager, simulate=False):
284282 successful_parent_package_install_count_in_batch_patching = self .successful_parent_package_install_count
285283
286284 if len (packages ) == 0 :
287- self .log_final_installation_metric ( patch_installation_successful , maintenance_window_exceeded , maintenance_window , installed_update_count )
285+ self .log_final_metrics ( maintenance_window , patch_installation_successful , maintenance_window_exceeded , installed_update_count )
288286 return installed_update_count , patch_installation_successful , maintenance_window_exceeded
289287 else :
290288 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 ),
@@ -383,7 +381,7 @@ def install_updates(self, maintenance_window, package_manager, simulate=False):
383381 self .composite_logger .log_debug ("\n Performing final system state reconciliation..." )
384382 installed_update_count += self .perform_status_reconciliation_conditionally (package_manager , True )
385383
386- self .log_final_installation_metric ( patch_installation_successful , maintenance_window_exceeded , maintenance_window , installed_update_count )
384+ self .log_final_metrics ( maintenance_window , patch_installation_successful , maintenance_window_exceeded , installed_update_count )
387385
388386 install_update_count_in_sequential_patching = installed_update_count - install_update_count_in_batch_patching
389387 attempted_parent_package_install_count_in_sequential_patching = self .attempted_parent_package_install_count - attempted_parent_package_install_count_in_batch_patching
@@ -420,7 +418,6 @@ def log_final_metrics(self, maintenance_window, patch_installation_successful, m
420418
421419 def log_final_warning_metric (self , maintenance_window , installed_update_count ):
422420 """ Log the final metrics for warning installation status. """
423-
424421 self .__log_progress_status (maintenance_window , installed_update_count )
425422 message = "All requested package(s) are installed. Any patch errors marked are from previous attempts."
426423 self .status_handler .add_error_to_status (message , Constants .PatchOperationErrorCodes .PACKAGES_RETRY_SUCCEEDED )
@@ -692,9 +689,12 @@ def mark_installation_completed(self):
692689
693690 def mark_installation_completed_with_warning (self ):
694691 """ Marks Installation operation as warning by updating the status of PatchInstallationSummary as warning and patch metadata to be sent to healthstore.
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 . """
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. """
697694
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,7 +812,11 @@ 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 ())), 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 ),
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 ),
816820 "Completed processing packages!" )
817821 self .composite_logger .log (progress_status )
818822
@@ -824,22 +828,5 @@ def __send_metadata_to_health_store(self):
824828 report_to_healthstore = True ,
825829 wait_after_update = False )
826830
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
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 ()
0 commit comments