Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove debug info from waagent.status.json #2971

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 1 addition & 29 deletions azurelinuxagent/ga/exthandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
from azurelinuxagent.common.utils import textutil
from azurelinuxagent.common.utils.archive import ARCHIVE_DIRECTORY_NAME
from azurelinuxagent.common.utils.flexible_version import FlexibleVersion
from azurelinuxagent.common.version import AGENT_NAME, CURRENT_VERSION, \
PY_VERSION_MAJOR, PY_VERSION_MICRO, PY_VERSION_MINOR
from azurelinuxagent.common.version import AGENT_NAME, CURRENT_VERSION

_HANDLER_NAME_PATTERN = r'^([^-]+)'
_HANDLER_VERSION_PATTERN = r'(\d+(?:\.\d+)*)'
Expand Down Expand Up @@ -964,33 +963,6 @@ def report_ext_handlers_status(self, goal_state_changed=False, vm_agent_update_s
message=msg)
return None

def get_ext_handlers_status_debug_info(self, vm_status):
status_blob_text = self.protocol.get_status_blob_data()
if status_blob_text is None:
status_blob_text = ""

support_multi_config = {}
vm_status_data = get_properties(vm_status)
vm_handler_statuses = vm_status_data.get('vmAgent', {}).get('extensionHandlers')
for handler_status in vm_handler_statuses:
if handler_status.get('name') is not None:
support_multi_config[handler_status.get('name')] = handler_status.get('supports_multi_config')

debug_text = json.dumps({
"agentName": AGENT_NAME,
"daemonVersion": str(version.get_daemon_version()),
"pythonVersion": "Python: {0}.{1}.{2}".format(PY_VERSION_MAJOR, PY_VERSION_MINOR, PY_VERSION_MICRO),
"extensionSupportedFeatures": [name for name, _ in get_agent_supported_features_list_for_extensions().items()],
"supportsMultiConfig": support_multi_config
})

return '''{{
"__comment__": "The __status__ property is the actual status reported to CRP",
"__status__": {0},
"__debug__": {1}
}}
'''.format(status_blob_text, debug_text)

def report_ext_handler_status(self, vm_status, ext_handler, goal_state_changed):
ext_handler_i = ExtHandlerInstance(ext_handler, self.protocol)

Expand Down
6 changes: 4 additions & 2 deletions azurelinuxagent/ga/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,10 @@ def _report_status(self, exthandlers_handler, agent_update_handler):
if vm_status is not None:
self._report_extensions_summary(vm_status)
if self._goal_state is not None:
agent_status = exthandlers_handler.get_ext_handlers_status_debug_info(vm_status)
self._goal_state.save_to_history(agent_status, AGENT_STATUS_FILE)
status_blob_text = exthandlers_handler.protocol.get_status_blob_data()
if status_blob_text is None:
status_blob_text = "{}"
self._goal_state.save_to_history(status_blob_text, AGENT_STATUS_FILE)
if self._goal_state.extensions_goal_state.is_outdated:
exthandlers_handler.protocol.client.get_host_plugin().clear_fast_track_state()

Expand Down
126 changes: 55 additions & 71 deletions tests/ga/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3247,91 +3247,75 @@ def mock_http_put(url, *args, **_):
)

expected_status = {
"__comment__": "The __status__ property is the actual status reported to CRP",
"__status__": {
"version": "1.1",
"timestampUTC": "1970-01-01T00:00:00Z",
"aggregateStatus": {
"guestAgentStatus": {
"version": AGENT_VERSION,
"version": "1.1",
"timestampUTC": "1970-01-01T00:00:00Z",
"aggregateStatus": {
"guestAgentStatus": {
"version": AGENT_VERSION,
"status": "Ready",
"formattedMessage": {
"lang": "en-US",
"message": "Guest Agent is running"
}
},
"handlerAggregateStatus": [
{
"handlerVersion": "1.0.0",
"handlerName": "OSTCExtensions.ExampleHandlerLinux",
"status": "Ready",
"code": 0,
"useExactVersion": True,
"formattedMessage": {
"lang": "en-US",
"message": "Guest Agent is running"
}
},
"handlerAggregateStatus": [
{
"handlerVersion": "1.0.0",
"handlerName": "OSTCExtensions.ExampleHandlerLinux",
"status": "Ready",
"code": 0,
"useExactVersion": True,
"formattedMessage": {
"lang": "en-US",
"message": "Plugin enabled"
},
"runtimeSettingsStatus": {
"settingsStatus": {
"status": {
"name": "OSTCExtensions.ExampleHandlerLinux",
"configurationAppliedTime": None,
"operation": None,
"status": "success",
"code": 0,
"formattedMessage": {
"lang": "en-US",
"message": None
}
},
"version": 1.0,
"timestampUTC": "1970-01-01T00:00:00Z"
"message": "Plugin enabled"
},
"runtimeSettingsStatus": {
"settingsStatus": {
"status": {
"name": "OSTCExtensions.ExampleHandlerLinux",
"configurationAppliedTime": None,
"operation": None,
"status": "success",
"code": 0,
"formattedMessage": {
"lang": "en-US",
"message": None
}
},
"sequenceNumber": 0
}
}
],
"vmArtifactsAggregateStatus": {
"goalStateAggregateStatus": {
"formattedMessage": {
"lang": "en-US",
"message": "GoalState executed successfully"
"version": 1.0,
"timestampUTC": "1970-01-01T00:00:00Z"
},
"timestampUTC": "1970-01-01T00:00:00Z",
"inSvdSeqNo": "1",
"status": "Success",
"code": 0
"sequenceNumber": 0
}
}
},
"guestOSInfo": None,
"supportedFeatures": supported_features
},
"__debug__": {
"agentName": AGENT_NAME,
"daemonVersion": "0.0.0.0",
"pythonVersion": "Python: {0}.{1}.{2}".format(PY_VERSION_MAJOR, PY_VERSION_MINOR, PY_VERSION_MICRO),
"extensionSupportedFeatures": [name for name, _ in get_agent_supported_features_list_for_extensions().items()],
"supportsMultiConfig": {
"OSTCExtensions.ExampleHandlerLinux": False
],
"vmArtifactsAggregateStatus": {
"goalStateAggregateStatus": {
"formattedMessage": {
"lang": "en-US",
"message": "GoalState executed successfully"
},
"timestampUTC": "1970-01-01T00:00:00Z",
"inSvdSeqNo": "1",
"status": "Success",
"code": 0
}
}
}
},
"guestOSInfo": None,
"supportedFeatures": supported_features
}


exthandlers_handler.run()
vm_status = exthandlers_handler.report_ext_handlers_status()
actual_status_json = json.loads(exthandlers_handler.get_ext_handlers_status_debug_info(vm_status))
exthandlers_handler.report_ext_handlers_status()

# Don't compare the guestOSInfo
status_property = actual_status_json.get("__status__")
self.assertIsNotNone(status_property, "The status file is missing the __status__ property")
self.assertIsNotNone(status_property.get("guestOSInfo"), "The status file is missing the guestOSInfo property")
status_property["guestOSInfo"] = None
actual_status = json.loads(protocol.get_status_blob_data())

actual_status_json.pop('guestOSInfo', None)
# Don't compare the guestOSInfo
self.assertIsNotNone(actual_status.get("guestOSInfo"), "The status file is missing the guestOSInfo property")
actual_status["guestOSInfo"] = None

self.assertEqual(expected_status, actual_status_json)
self.assertEqual(expected_status, actual_status)

def test_it_should_process_extensions_only_if_allowed(self):
def assert_extensions_called(exthandlers_handler, expected_call_count=0):
Expand Down
1 change: 0 additions & 1 deletion tests/ga/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,6 @@ def create_vm_status(extension_status):
exthandlers_handler.report_ext_handlers_status = Mock(return_value=create_vm_status(ExtensionStatusValue.success))
else:
exthandlers_handler.report_ext_handlers_status = Mock(side_effect=[create_vm_status(s) for s in extension_statuses])
exthandlers_handler.get_ext_handlers_status_debug_info = Mock(return_value='')
yield exthandlers_handler


Expand Down
Loading