Skip to content

Commit

Permalink
Informational message requested added.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohn-msft committed Oct 31, 2023
1 parent 67c2a4f commit 606c3ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/src/bootstrap/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class PatchOperationTopLevelErrorCode(EnumBackport):
ERROR = 1

class PatchOperationErrorCodes(EnumBackport):
INFORMATIONAL = "INFORMATIONAL"
DEFAULT_ERROR = "ERROR" # default error code
OPERATION_FAILED = "OPERATION_FAILED"
PACKAGE_MANAGER_FAILURE = "PACKAGE_MANAGER_FAILURE"
Expand Down Expand Up @@ -310,6 +311,7 @@ class TelemetryTaskName(EnumBackport):
TELEMETRY_NOT_COMPATIBLE_ERROR_MSG = "Unsupported older Azure Linux Agent version. To resolve: http://aka.ms/UpdateLinuxAgent"
TELEMETRY_COMPATIBLE_MSG = "Minimum Azure Linux Agent version prerequisite met"
PYTHON_NOT_COMPATIBLE_ERROR_MSG = "Unsupported older Python version. Minimum Python version required is 2.7. [DetectedPythonVersion={0}]"
INFO_STRICT_SDP_SUCCESS = "Success: Safely patched your VM in a AzGPS-coordinated global rollout. https://aka.ms/AzGPS/StrictSDP [Target={0}]"
UTC_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"

# EnvLayer Constants
Expand Down
3 changes: 3 additions & 0 deletions src/core/src/core_logic/PatchInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def start_installation(self, simulate=False):
""" Strict SDP with the package manager that supports it """
installed_update_count, update_run_successful, maintenance_window_exceeded = self.install_updates_azgps_coordinated(maintenance_window, package_manager, simulate)
package_manager.set_package_manager_setting(Constants.PACKAGE_MGR_SETTING_REPEAT_PATCH_OPERATION, bool(not update_run_successful))
if update_run_successful:
self.composite_logger.log_debug(Constants.INFO_STRICT_SDP_SUCCESS.format(self.execution_config.max_patch_publish_date))
self.status_handler.add_error_to_status(Constants.INFO_STRICT_SDP_SUCCESS.format(self.execution_config.max_patch_publish_date), error_code=Constants.PatchOperationErrorCodes.INFORMATIONAL)
else:
""" Regular patch installation flow - non-AzGPS-coordinated and (AzGPS-coordinated without strict SDP)"""
installed_update_count, update_run_successful, maintenance_window_exceeded = self.install_updates(maintenance_window, package_manager, simulate)
Expand Down
9 changes: 7 additions & 2 deletions src/core/src/service_interfaces/StatusHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,13 @@ def __try_add_error(error_list, detail):

def __set_errors_json(self, error_count_by_operation, errors_by_operation):
""" Compose the error object json to be added in 'errors' in given operation's summary """
message = "{0} error/s reported.".format(error_count_by_operation)
message += " The latest {0} error/s are shared in detail. To view all errors, review this log file on the machine: {1}".format(len(errors_by_operation), self.__log_file_path) if error_count_by_operation > 0 else ""
if error_count_by_operation == 1 and errors_by_operation[0]['code'] == Constants.PatchOperationErrorCodes.INFORMATIONAL: # special-casing for single informational messages
message = errors_by_operation[0]['message']
errors_by_operation = []
error_count_by_operation = 0
else:
message = "{0} error/s reported.".format(error_count_by_operation)
message += " The latest {0} error/s are shared in detail. To view all errors, review this log file on the machine: {1}".format(len(errors_by_operation), self.__log_file_path) if error_count_by_operation > 0 else ""
return {
"code": Constants.PatchOperationTopLevelErrorCode.SUCCESS if error_count_by_operation == 0 else Constants.PatchOperationTopLevelErrorCode.ERROR,
"details": errors_by_operation,
Expand Down

0 comments on commit 606c3ff

Please sign in to comment.