Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/src/core_logic/ConfigurePatchingProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def start_configure_patching(self):
overall_status = Constants.STATUS_SUCCESS if self.configure_patching_successful else Constants.STATUS_ERROR
self.__report_consolidated_configure_patch_status(overall_status)
except Exception as error:
self.current_auto_assessment_state = Constants.AutoAssessmentStates.ERROR
self.__report_consolidated_configure_patch_status(status=Constants.STATUS_ERROR, error=error)
self.configure_patching_successful &= False

Expand Down Expand Up @@ -128,6 +129,7 @@ def __report_consolidated_configure_patch_status(self, status=Constants.STATUS_T
error_msg = 'Error: ' + repr(error)
self.composite_logger.log_error(error_msg)
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.DEFAULT_ERROR)
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.DEFAULT_ERROR, current_operation_override_for_error=Constants.CONFIGURE_PATCHING_AUTO_ASSESSMENT)

# write consolidated status
self.status_handler.set_configure_patching_substatus_json(status=status,
Expand All @@ -140,7 +142,6 @@ def __raise_if_agent_incompatible(self):
return
if not self.telemetry_writer.is_agent_compatible():
error_msg = "{0} [{1}]".format(Constants.TELEMETRY_AT_AGENT_NOT_COMPATIBLE_ERROR_MSG, self.telemetry_writer.get_telemetry_diagnostics())
self.composite_logger.log_error(error_msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line removed because __report_consolidated_configure_patch_status logs the error, so this results in duplicate messages (at least, without the duplicate checking code that exists).

raise Exception(error_msg)

self.composite_logger.log("{0} [{1}]".format(Constants.TELEMETRY_AT_AGENT_COMPATIBLE_MSG, self.telemetry_writer.get_telemetry_diagnostics()))
1 change: 1 addition & 0 deletions src/core/src/core_logic/PatchAssessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def raise_if_agent_incompatible(self):
if not self.telemetry_writer.is_agent_compatible():
error_msg = "{0} [{1}]".format(Constants.TELEMETRY_AT_AGENT_NOT_COMPATIBLE_ERROR_MSG, self.telemetry_writer.get_telemetry_diagnostics())
self.composite_logger.log_error(error_msg)
self.status_handler.set_assessment_substatus_json(status=Constants.STATUS_ERROR)
raise Exception(error_msg)

self.composite_logger.log("{0} [{1}]".format(Constants.TELEMETRY_AT_AGENT_COMPATIBLE_MSG, self.telemetry_writer.get_telemetry_diagnostics()))
Expand Down
2 changes: 2 additions & 0 deletions src/core/tests/Test_ConfigurePatchingProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def test_operation_fail_for_configure_patching_agent_incompatible(self):
self.assertTrue(substatus_file_data[0]["status"].lower() == Constants.STATUS_ERROR.lower())
self.assertTrue(len(json.loads(substatus_file_data[0]["formattedMessage"]["message"])["errors"]["details"]), 1)
self.assertTrue(Constants.TELEMETRY_AT_AGENT_NOT_COMPATIBLE_ERROR_MSG in json.loads(substatus_file_data[0]["formattedMessage"]["message"])["errors"]["details"][0]["message"])
self.assertTrue(Constants.TELEMETRY_AT_AGENT_NOT_COMPATIBLE_ERROR_MSG in json.loads(substatus_file_data[0]["formattedMessage"]["message"])["autoAssessmentStatus"]["errors"]["details"][0]["message"])
self.assertTrue(Constants.STATUS_ERROR in json.loads(substatus_file_data[0]["formattedMessage"]["message"])["autoAssessmentStatus"]["autoAssessmentState"])
else:
self.assertTrue(substatus_file_data[0]["status"].lower() == Constants.STATUS_SUCCESS.lower())
runtime.stop()
Expand Down
9 changes: 9 additions & 0 deletions src/core/tests/Test_PatchAssessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import json
import unittest

from core.src.service_interfaces.TelemetryWriter import TelemetryWriter
from core.tests.library.ArgumentComposer import ArgumentComposer
from core.tests.library.RuntimeCompositor import RuntimeCompositor

Expand Down Expand Up @@ -51,6 +53,13 @@ def test_assessment_fail_with_status_update(self):
file_contents = json.loads(file_handle.read())
self.assertTrue('Unexpected return code (100) from package manager on command: LANG=en_US.UTF8 sudo apt-get -s dist-upgrade' in str(file_contents))

def test_assessment_telemetry_fail(self):
backup_telemetry_writer = self.runtime.telemetry_writer
telemetry_writer = TelemetryWriter(self.runtime.env_layer, self.runtime.composite_logger, events_folder_path=None)
self.runtime.patch_assessor.telemetry_writer = telemetry_writer
self.assertRaises(Exception, self.runtime.patch_assessor.start_assessment)
self.runtime.patch_assessor.telemetry_writer = backup_telemetry_writer

def mock_refresh_repo(self):
pass

Expand Down