From 2308d7de0d9d524ea9e6a503be272917a56478ce Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Wed, 7 Jan 2026 15:42:05 -0800 Subject: [PATCH 1/8] add status timestamp check --- proxy_agent_extension/src/constants.rs | 5 + proxy_agent_extension/src/service_main.rs | 277 +++++++++++++++++++++- proxy_agent_shared/src/misc_helpers.rs | 4 + 3 files changed, 285 insertions(+), 1 deletion(-) diff --git a/proxy_agent_extension/src/constants.rs b/proxy_agent_extension/src/constants.rs index 4415bf02..e66ffd4f 100644 --- a/proxy_agent_extension/src/constants.rs +++ b/proxy_agent_extension/src/constants.rs @@ -67,6 +67,11 @@ pub const MIN_SUPPORTED_OS_BUILD: u32 = 17763; pub const STATE_KEY_READ_PROXY_AGENT_STATUS_FILE: &str = "ReadProxyAgentStatusFile"; pub const STATE_KEY_FILE_VERSION: &str = "FileVersion"; +pub const STATE_KEY_STALE_PROXY_AGENT_STATUS: &str = "StaleProxyAgentStatus"; +pub const STATE_KEY_PARSE_TIMESTAMP_ERROR: &str = "ParseTimestampError"; + +// Max time in seconds before proxy agent status is considered stale +pub const MAX_TIME_BEFORE_STALE_STATUS_SECS: u64 = 5 * 60; pub const EBPF_CORE: &str = "EbpfCore"; pub const EBPF_EXT: &str = "NetEbpfExt"; diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index 120ca171..0b6a0cee 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -428,10 +428,111 @@ fn extension_substatus( status_state_obj: &mut common::StatusState, service_state: &mut ServiceState, ) { + let proxy_agent_status_timestamp_result = proxy_agent_aggregate_status_top_level.get_status_timestamp(); let proxy_agent_aggregate_status_obj = proxy_agent_aggregate_status_top_level.proxyAgentStatus; - let proxy_agent_aggregate_status_file_version = proxy_agent_aggregate_status_obj.version.to_string(); + + // Compare the timestamp in the proxy agent aggregate status file with current time, if the time is greater than 5 minutes then the status is stale + match proxy_agent_status_timestamp_result { + Ok(status_timestamp) => { + let current_time = misc_helpers::get_current_utc_time(); + let duration = current_time - status_timestamp; + if duration > Duration::from_secs(constants::MAX_TIME_BEFORE_STALE_STATUS_SECS) { + let stale_message = format!("Proxy agent aggregate status file is stale. Status timestamp: {}, Current time: {}", status_timestamp, current_time); + write_state_event( + constants::STATE_KEY_STALE_PROXY_AGENT_STATUS, + constants::ERROR_STATUS, + stale_message.to_string(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + service_state, + ); + status.status = status_state_obj.update_state(false); + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + status.substatus = { + vec![ + SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: stale_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: stale_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: stale_message.to_string(), + }, + }, + ] + }; + return; + } + } + Err(e) => { + let error_message = format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"); + write_state_event( + constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, + constants::ERROR_STATUS, + error_message.to_string(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + service_state, + ); + status.status = status_state_obj.update_state(false); + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + status.substatus = { + vec![ + SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + ] + }; + return; + } + } + // Compare GPA version between proxy agent aggregate status file and proxy agent file in extension if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { status.status = status_state_obj.update_state(false); let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); @@ -1105,4 +1206,178 @@ mod tests { assert_eq!(connection_summary, orig_conn); assert_eq!(failed_auth_summary, orig_auth); } + + #[test] + fn test_stale_status_timestamp_greater_than_5_minutes() { + let proxy_agent_status_obj = ProxyAgentStatus { + version: "1.0.0".to_string(), + status: OverallState::SUCCESS, + monitorStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + keyLatchStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + ebpfProgramStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + proxyListenerStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + telemetryLoggerStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + proxyConnectionsCount: 1, + }; + + let proxy_connection_summary_obj = ProxyConnectionSummary { + userName: "test".to_string(), + ip: "test".to_string(), + port: 1, + processCmdLine: "test".to_string(), + responseStatus: "test".to_string(), + count: 1, + processFullPath: Some("test".to_string()), + userGroups: Some(vec!["test".to_string()]), + }; + + // Create a timestamp that is 10 minutes old (greater than 5 minutes) + // Use a fixed old timestamp format to simulate staleness + let stale_timestamp = "2024-01-01T00:00:00Z".to_string(); + + let toplevel_status = GuestProxyAgentAggregateStatus { + timestamp: stale_timestamp, + proxyAgentStatus: proxy_agent_status_obj, + proxyConnectionSummary: vec![proxy_connection_summary_obj.clone()], + failedAuthenticateSummary: vec![proxy_connection_summary_obj], + }; + + let mut status = StatusObj { + name: constants::PLUGIN_NAME.to_string(), + operation: constants::ENABLE_OPERATION.to_string(), + configurationAppliedTime: misc_helpers::get_date_time_string(), + code: constants::STATUS_CODE_OK, + status: constants::SUCCESS_STATUS.to_string(), + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: "Update Proxy Agent command output successfully".to_string(), + }, + substatus: Default::default(), + }; + + let mut status_state_obj = super::common::StatusState::new(); + let proxyagent_file_version_in_extension: &String = &"1.0.0".to_string(); + let mut service_state = super::service_state::ServiceState::default(); + + super::extension_substatus( + toplevel_status, + proxyagent_file_version_in_extension, + &mut status, + &mut status_state_obj, + &mut service_state, + ); + + // Verify that status is not successful due to stale timestamp + assert_ne!(status.status, constants::SUCCESS_STATUS.to_string()); + assert_eq!(status.substatus.len(), 3); + assert_eq!(status.substatus[0].status, constants::TRANSITIONING_STATUS.to_string()); + assert_eq!(status.substatus[0].code, constants::STATUS_CODE_NOT_OK); + assert!(status.substatus[0].formattedMessage.message.contains("stale")); + } + + #[test] + fn test_fresh_status_timestamp_within_5_minutes() { + let proxy_agent_status_obj = ProxyAgentStatus { + version: "1.0.0".to_string(), + status: OverallState::SUCCESS, + monitorStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + keyLatchStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + ebpfProgramStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + proxyListenerStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + telemetryLoggerStatus: ProxyAgentDetailStatus { + status: ModuleState::RUNNING, + message: "test".to_string(), + states: None, + }, + proxyConnectionsCount: 1, + }; + + let proxy_connection_summary_obj = ProxyConnectionSummary { + userName: "test".to_string(), + ip: "test".to_string(), + port: 1, + processCmdLine: "test".to_string(), + responseStatus: "test".to_string(), + count: 1, + processFullPath: Some("test".to_string()), + userGroups: Some(vec!["test".to_string()]), + }; + + // Create a fresh timestamp (current time) + let fresh_timestamp = misc_helpers::get_date_time_string(); + + let toplevel_status = GuestProxyAgentAggregateStatus { + timestamp: fresh_timestamp, + proxyAgentStatus: proxy_agent_status_obj, + proxyConnectionSummary: vec![proxy_connection_summary_obj.clone()], + failedAuthenticateSummary: vec![proxy_connection_summary_obj], + }; + + let mut status = StatusObj { + name: constants::PLUGIN_NAME.to_string(), + operation: constants::ENABLE_OPERATION.to_string(), + configurationAppliedTime: misc_helpers::get_date_time_string(), + code: constants::STATUS_CODE_OK, + status: constants::SUCCESS_STATUS.to_string(), + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: "Update Proxy Agent command output successfully".to_string(), + }, + substatus: Default::default(), + }; + + let mut status_state_obj = super::common::StatusState::new(); + let proxyagent_file_version_in_extension: &String = &"1.0.0".to_string(); + let mut service_state = super::service_state::ServiceState::default(); + + super::extension_substatus( + toplevel_status, + proxyagent_file_version_in_extension, + &mut status, + &mut status_state_obj, + &mut service_state, + ); + + // Verify that status is successful with fresh timestamp + assert_eq!(status.status, constants::SUCCESS_STATUS.to_string()); + assert_eq!(status.substatus.len(), 3); + assert_eq!(status.substatus[0].status, constants::SUCCESS_STATUS.to_string()); + assert_eq!(status.substatus[0].code, constants::STATUS_CODE_OK); + } } diff --git a/proxy_agent_shared/src/misc_helpers.rs b/proxy_agent_shared/src/misc_helpers.rs index d8631098..b6ee12b2 100644 --- a/proxy_agent_shared/src/misc_helpers.rs +++ b/proxy_agent_shared/src/misc_helpers.rs @@ -57,6 +57,10 @@ pub fn get_date_time_unix_nano() -> i128 { OffsetDateTime::now_utc().unix_timestamp_nanos() } +pub fn get_current_utc_time() -> OffsetDateTime { + OffsetDateTime::now_utc() +} + /// Parse a datetime string to OffsetDateTime (UTC) /// Supports multiple formats: /// - ISO 8601 with/without 'Z': "YYYY-MM-DDTHH:MM:SS" or "YYYY-MM-DDTHH:MM:SSZ" From 90738706488e328936622e8a8162a065e421dd12 Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Wed, 7 Jan 2026 15:45:07 -0800 Subject: [PATCH 2/8] linter --- proxy_agent_extension/src/service_main.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index 0b6a0cee..db43cf96 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -428,7 +428,8 @@ fn extension_substatus( status_state_obj: &mut common::StatusState, service_state: &mut ServiceState, ) { - let proxy_agent_status_timestamp_result = proxy_agent_aggregate_status_top_level.get_status_timestamp(); + let proxy_agent_status_timestamp_result = + proxy_agent_aggregate_status_top_level.get_status_timestamp(); let proxy_agent_aggregate_status_obj = proxy_agent_aggregate_status_top_level.proxyAgentStatus; let proxy_agent_aggregate_status_file_version = proxy_agent_aggregate_status_obj.version.to_string(); @@ -483,10 +484,11 @@ fn extension_substatus( ] }; return; - } + } } Err(e) => { - let error_message = format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"); + let error_message = + format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"); write_state_event( constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, constants::ERROR_STATUS, @@ -1290,9 +1292,15 @@ mod tests { // Verify that status is not successful due to stale timestamp assert_ne!(status.status, constants::SUCCESS_STATUS.to_string()); assert_eq!(status.substatus.len(), 3); - assert_eq!(status.substatus[0].status, constants::TRANSITIONING_STATUS.to_string()); + assert_eq!( + status.substatus[0].status, + constants::TRANSITIONING_STATUS.to_string() + ); assert_eq!(status.substatus[0].code, constants::STATUS_CODE_NOT_OK); - assert!(status.substatus[0].formattedMessage.message.contains("stale")); + assert!(status.substatus[0] + .formattedMessage + .message + .contains("stale")); } #[test] @@ -1377,7 +1385,10 @@ mod tests { // Verify that status is successful with fresh timestamp assert_eq!(status.status, constants::SUCCESS_STATUS.to_string()); assert_eq!(status.substatus.len(), 3); - assert_eq!(status.substatus[0].status, constants::SUCCESS_STATUS.to_string()); + assert_eq!( + status.substatus[0].status, + constants::SUCCESS_STATUS.to_string() + ); assert_eq!(status.substatus[0].code, constants::STATUS_CODE_OK); } } From 7bb3fd87d5eafdf900cb0df5f3911f9ed4d3764d Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 10:43:23 -0800 Subject: [PATCH 3/8] code refactor --- proxy_agent_extension/src/service_main.rs | 99 +++++------------------ 1 file changed, 22 insertions(+), 77 deletions(-) diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index db43cf96..cc4784da 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -434,8 +434,8 @@ fn extension_substatus( let proxy_agent_aggregate_status_file_version = proxy_agent_aggregate_status_obj.version.to_string(); - // Compare the timestamp in the proxy agent aggregate status file with current time, if the time is greater than 5 minutes then the status is stale - match proxy_agent_status_timestamp_result { + // Check for timestamp staleness or parse errors + let timestamp_error = match proxy_agent_status_timestamp_result { Ok(status_timestamp) => { let current_time = misc_helpers::get_current_utc_time(); let duration = current_time - status_timestamp; @@ -450,40 +450,9 @@ fn extension_substatus( &logger::get_logger_key(), service_state, ); - status.status = status_state_obj.update_state(false); - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - status.substatus = { - vec![ - SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: stale_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: stale_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: stale_message.to_string(), - }, - }, - ] - }; - return; + Some(stale_message) + } else { + None } } Err(e) => { @@ -498,45 +467,14 @@ fn extension_substatus( &logger::get_logger_key(), service_state, ); - status.status = status_state_obj.update_state(false); - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - status.substatus = { - vec![ - SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - ] - }; - return; + Some(error_message) } - } - // Compare GPA version between proxy agent aggregate status file and proxy agent file in extension - if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { - status.status = status_state_obj.update_state(false); + }; + + // Determine error message for status reporting + let error_message = if let Some(timestamp_error) = timestamp_error { + Some(timestamp_error) + } else if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); write_state_event( constants::STATE_KEY_FILE_VERSION, @@ -547,6 +485,13 @@ fn extension_substatus( &logger::get_logger_key(), service_state, ); + Some(version_mismatch_message) + } else { + None + }; + + if let Some(error_message) = error_message { + status.status = status_state_obj.update_state(false); status.configurationAppliedTime = misc_helpers::get_date_time_string(); status.substatus = { vec![ @@ -556,7 +501,7 @@ fn extension_substatus( code: constants::STATUS_CODE_NOT_OK, formattedMessage: FormattedMessage { lang: constants::LANG_EN_US.to_string(), - message: version_mismatch_message.to_string(), + message: error_message.to_string(), }, }, SubStatus { @@ -565,7 +510,7 @@ fn extension_substatus( code: constants::STATUS_CODE_NOT_OK, formattedMessage: FormattedMessage { lang: constants::LANG_EN_US.to_string(), - message: version_mismatch_message.to_string(), + message: error_message.to_string(), }, }, SubStatus { @@ -574,7 +519,7 @@ fn extension_substatus( code: constants::STATUS_CODE_NOT_OK, formattedMessage: FormattedMessage { lang: constants::LANG_EN_US.to_string(), - message: version_mismatch_message.to_string(), + message: error_message.to_string(), }, }, ] From a70d917df9d6dde6dfc4e6fc247321a20e7b4926 Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 11:14:11 -0800 Subject: [PATCH 4/8] add report_error_status() --- proxy_agent_extension/src/service_main.rs | 131 ++++++++++------------ 1 file changed, 57 insertions(+), 74 deletions(-) diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index cc4784da..3df0f1da 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -237,6 +237,57 @@ fn write_state_event( } } +fn report_error_status( + status: &mut StatusObj, + status_state_obj: &mut common::StatusState, + service_state: &mut ServiceState, + error_key: &str, + error_message: String, +) { + status.status = status_state_obj.update_state(false); + write_state_event( + error_key, + constants::ERROR_STATUS, + error_message.to_string(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + service_state, + ); + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + status.substatus = { + vec![ + SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + ] + }; +} + #[cfg(windows)] fn report_ebpf_status(status_obj: &mut StatusObj) { match service::check_service_installed(constants::EBPF_CORE) { @@ -440,90 +491,22 @@ fn extension_substatus( let current_time = misc_helpers::get_current_utc_time(); let duration = current_time - status_timestamp; if duration > Duration::from_secs(constants::MAX_TIME_BEFORE_STALE_STATUS_SECS) { - let stale_message = format!("Proxy agent aggregate status file is stale. Status timestamp: {}, Current time: {}", status_timestamp, current_time); - write_state_event( - constants::STATE_KEY_STALE_PROXY_AGENT_STATUS, - constants::ERROR_STATUS, - stale_message.to_string(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - service_state, - ); - Some(stale_message) + Some((constants::STATE_KEY_STALE_PROXY_AGENT_STATUS, format!("Proxy agent aggregate status file is stale. Status timestamp: {}, Current time: {}", status_timestamp, current_time))) } else { None } } Err(e) => { - let error_message = - format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"); - write_state_event( - constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, - constants::ERROR_STATUS, - error_message.to_string(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - service_state, - ); - Some(error_message) + Some((constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"))) } }; - // Determine error message for status reporting - let error_message = if let Some(timestamp_error) = timestamp_error { - Some(timestamp_error) + // Determine error for status reporting + if let Some((error_key, error_message)) = timestamp_error { + report_error_status(status, status_state_obj, service_state, error_key, error_message); } else if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); - write_state_event( - constants::STATE_KEY_FILE_VERSION, - constants::ERROR_STATUS, - version_mismatch_message.to_string(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - service_state, - ); - Some(version_mismatch_message) - } else { - None - }; - - if let Some(error_message) = error_message { - status.status = status_state_obj.update_state(false); - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - status.substatus = { - vec![ - SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - ] - }; + report_error_status(status, status_state_obj, service_state, constants::STATE_KEY_FILE_VERSION, version_mismatch_message); } // Success Status and report to status file for CRP to read from else { From 488f3d88e60e94730fe2dacc3c919f4f3e42abf3 Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 11:18:29 -0800 Subject: [PATCH 5/8] move report error status to common --- proxy_agent_extension/src/common.rs | 58 +++++++++++++++++++++++ proxy_agent_extension/src/service_main.rs | 57 ++-------------------- 2 files changed, 61 insertions(+), 54 deletions(-) diff --git a/proxy_agent_extension/src/common.rs b/proxy_agent_extension/src/common.rs index 4d5ce712..06d91d33 100644 --- a/proxy_agent_extension/src/common.rs +++ b/proxy_agent_extension/src/common.rs @@ -113,6 +113,64 @@ pub fn report_status( } } +pub fn report_error_status( + status: &mut structs::StatusObj, + status_state_obj: &mut StatusState, + service_state: &mut crate::service_main::service_state::ServiceState, + error_key: &str, + error_message: String, +) { + use proxy_agent_shared::logger::LoggerLevel; + use proxy_agent_shared::telemetry::event_logger; + + status.status = status_state_obj.update_state(false); + if service_state.update_service_state_entry( + error_key, + constants::ERROR_STATUS, + crate::service_main::MAX_STATE_COUNT, + ) { + event_logger::write_event( + LoggerLevel::Info, + error_message.clone(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + ); + } + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + status.substatus = { + vec![ + structs::SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + structs::SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + structs::SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + ] + }; +} + /// Update the current seq no in the CURRENT_SEQ_NO_FILE /// If the seq no is different from the current seq no, update the seq no in the file /// If the seq no is same as the current seq no, do not update the seq no in the file diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index 3df0f1da..ab277450 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -23,7 +23,7 @@ pub mod windows_main; #[cfg(windows)] use proxy_agent_shared::service; -const MAX_STATE_COUNT: u32 = 120; +pub const MAX_STATE_COUNT: u32 = 120; pub fn run() { let message = format!( @@ -237,57 +237,6 @@ fn write_state_event( } } -fn report_error_status( - status: &mut StatusObj, - status_state_obj: &mut common::StatusState, - service_state: &mut ServiceState, - error_key: &str, - error_message: String, -) { - status.status = status_state_obj.update_state(false); - write_state_event( - error_key, - constants::ERROR_STATUS, - error_message.to_string(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - service_state, - ); - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - status.substatus = { - vec![ - SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - ] - }; -} - #[cfg(windows)] fn report_ebpf_status(status_obj: &mut StatusObj) { match service::check_service_installed(constants::EBPF_CORE) { @@ -503,10 +452,10 @@ fn extension_substatus( // Determine error for status reporting if let Some((error_key, error_message)) = timestamp_error { - report_error_status(status, status_state_obj, service_state, error_key, error_message); + common::report_error_status(status, status_state_obj, service_state, error_key, error_message); } else if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); - report_error_status(status, status_state_obj, service_state, constants::STATE_KEY_FILE_VERSION, version_mismatch_message); + common::report_error_status(status, status_state_obj, service_state, constants::STATE_KEY_FILE_VERSION, version_mismatch_message); } // Success Status and report to status file for CRP to read from else { From 7b35e0d3178c34f2bb8bbb0399cc79092760cf8c Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 11:34:57 -0800 Subject: [PATCH 6/8] lint --- proxy_agent_extension/src/service_main.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index ab277450..7b360b33 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -445,17 +445,30 @@ fn extension_substatus( None } } - Err(e) => { - Some((constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"))) - } + Err(e) => Some(( + constants::STATE_KEY_PARSE_TIMESTAMP_ERROR, + format!("Error in parsing timestamp from proxy agent aggregate status file: {e}"), + )), }; // Determine error for status reporting if let Some((error_key, error_message)) = timestamp_error { - common::report_error_status(status, status_state_obj, service_state, error_key, error_message); + common::report_error_status( + status, + status_state_obj, + service_state, + error_key, + error_message, + ); } else if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); - common::report_error_status(status, status_state_obj, service_state, constants::STATE_KEY_FILE_VERSION, version_mismatch_message); + common::report_error_status( + status, + status_state_obj, + service_state, + constants::STATE_KEY_FILE_VERSION, + version_mismatch_message, + ); } // Success Status and report to status file for CRP to read from else { From 546051629bf67a74ffdcdad13c257adfc7ec05b3 Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 13:48:22 -0800 Subject: [PATCH 7/8] move report error status to service main --- proxy_agent_extension/src/common.rs | 58 ----- proxy_agent_extension/src/service_main.rs | 280 +++++++++++++--------- 2 files changed, 169 insertions(+), 169 deletions(-) diff --git a/proxy_agent_extension/src/common.rs b/proxy_agent_extension/src/common.rs index 06d91d33..4d5ce712 100644 --- a/proxy_agent_extension/src/common.rs +++ b/proxy_agent_extension/src/common.rs @@ -113,64 +113,6 @@ pub fn report_status( } } -pub fn report_error_status( - status: &mut structs::StatusObj, - status_state_obj: &mut StatusState, - service_state: &mut crate::service_main::service_state::ServiceState, - error_key: &str, - error_message: String, -) { - use proxy_agent_shared::logger::LoggerLevel; - use proxy_agent_shared::telemetry::event_logger; - - status.status = status_state_obj.update_state(false); - if service_state.update_service_state_entry( - error_key, - constants::ERROR_STATUS, - crate::service_main::MAX_STATE_COUNT, - ) { - event_logger::write_event( - LoggerLevel::Info, - error_message.clone(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - ); - } - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - status.substatus = { - vec![ - structs::SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - structs::SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - structs::SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::TRANSITIONING_STATUS.to_string(), - code: constants::STATUS_CODE_NOT_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: error_message.to_string(), - }, - }, - ] - }; -} - /// Update the current seq no in the CURRENT_SEQ_NO_FILE /// If the seq no is different from the current seq no, update the seq no in the file /// If the seq no is same as the current seq no, do not update the seq no in the file diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index 7b360b33..e9280b35 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -23,7 +23,7 @@ pub mod windows_main; #[cfg(windows)] use proxy_agent_shared::service; -pub const MAX_STATE_COUNT: u32 = 120; +const MAX_STATE_COUNT: u32 = 120; pub fn run() { let message = format!( @@ -421,6 +421,64 @@ fn report_proxy_agent_aggregate_status( } } +fn report_error_status( + status: &mut StatusObj, + status_state_obj: &mut common::StatusState, + service_state: &mut ServiceState, + error_key: &str, + error_message: String, +) { + use proxy_agent_shared::logger::LoggerLevel; + use proxy_agent_shared::telemetry::event_logger; + + status.status = status_state_obj.update_state(false); + if service_state.update_service_state_entry( + error_key, + constants::ERROR_STATUS, + MAX_STATE_COUNT, + ) { + event_logger::write_event( + LoggerLevel::Info, + error_message.clone(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + ); + } + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + status.substatus = { + vec![ + SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::TRANSITIONING_STATUS.to_string(), + code: constants::STATUS_CODE_NOT_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: error_message.to_string(), + }, + }, + ] + }; +} + fn extension_substatus( proxy_agent_aggregate_status_top_level: GuestProxyAgentAggregateStatus, proxyagent_file_version_in_extension: &String, @@ -453,141 +511,141 @@ fn extension_substatus( // Determine error for status reporting if let Some((error_key, error_message)) = timestamp_error { - common::report_error_status( + report_error_status( status, status_state_obj, service_state, error_key, error_message, ); + return; } else if proxy_agent_aggregate_status_file_version != *proxyagent_file_version_in_extension { let version_mismatch_message = format!("Proxy agent aggregate status file version {proxy_agent_aggregate_status_file_version} does not match proxy agent file version in extension {proxyagent_file_version_in_extension}"); - common::report_error_status( + report_error_status( status, status_state_obj, service_state, constants::STATE_KEY_FILE_VERSION, version_mismatch_message, ); + return; } // Success Status and report to status file for CRP to read from - else { - let substatus_proxy_agent_message = - match serde_json::to_string(&proxy_agent_aggregate_status_obj) { - Ok(proxy_agent_aggregate_status) => proxy_agent_aggregate_status, - Err(e) => { - let error_message = - format!("Error in serializing proxy agent aggregate status: {e}"); - logger::write(error_message.to_string()); - error_message - } - }; - let mut substatus_proxy_agent_connection_message: String; - if !proxy_agent_aggregate_status_top_level - .proxyConnectionSummary - .is_empty() - { - let proxy_agent_aggregate_connection_status_obj = get_top_proxy_connection_summary( - proxy_agent_aggregate_status_top_level - .proxyConnectionSummary - .clone(), - constants::MAX_CONNECTION_SUMMARY_LEN, - ); - match serde_json::to_string(&proxy_agent_aggregate_connection_status_obj) { - Ok(proxy_agent_aggregate_connection_status) => { - substatus_proxy_agent_connection_message = - proxy_agent_aggregate_connection_status; - } - Err(e) => { - let error_message = format!( - "Error in serializing proxy agent aggregate connection status: {e}" - ); - logger::write(error_message.to_string()); - substatus_proxy_agent_connection_message = error_message; - } + let substatus_proxy_agent_message = + match serde_json::to_string(&proxy_agent_aggregate_status_obj) { + Ok(proxy_agent_aggregate_status) => proxy_agent_aggregate_status, + Err(e) => { + let error_message = + format!("Error in serializing proxy agent aggregate status: {e}"); + logger::write(error_message.to_string()); + error_message + } + }; + let mut substatus_proxy_agent_connection_message: String; + if !proxy_agent_aggregate_status_top_level + .proxyConnectionSummary + .is_empty() + { + let proxy_agent_aggregate_connection_status_obj = get_top_proxy_connection_summary( + proxy_agent_aggregate_status_top_level + .proxyConnectionSummary + .clone(), + constants::MAX_CONNECTION_SUMMARY_LEN, + ); + match serde_json::to_string(&proxy_agent_aggregate_connection_status_obj) { + Ok(proxy_agent_aggregate_connection_status) => { + substatus_proxy_agent_connection_message = + proxy_agent_aggregate_connection_status; + } + Err(e) => { + let error_message = format!( + "Error in serializing proxy agent aggregate connection status: {e}" + ); + logger::write(error_message.to_string()); + substatus_proxy_agent_connection_message = error_message; } - } else { - logger::write("proxy connection summary is empty".to_string()); - substatus_proxy_agent_connection_message = - "proxy connection summary is empty".to_string(); } - let mut substatus_failed_auth_message: String; - if !proxy_agent_aggregate_status_top_level - .failedAuthenticateSummary - .is_empty() - { - let proxy_agent_aggregate_failed_auth_status_obj = get_top_proxy_connection_summary( - proxy_agent_aggregate_status_top_level - .failedAuthenticateSummary - .clone(), - constants::MAX_FAILED_AUTH_SUMMARY_LEN, - ); - match serde_json::to_string(&proxy_agent_aggregate_failed_auth_status_obj) { - Ok(proxy_agent_aggregate_failed_auth_status) => { - substatus_failed_auth_message = proxy_agent_aggregate_failed_auth_status; - } - Err(e) => { - let error_message = format!( - "Error in serializing proxy agent aggregate failed auth status: {e}" - ); - logger::write(error_message.to_string()); - substatus_failed_auth_message = error_message; - } + } else { + logger::write("proxy connection summary is empty".to_string()); + substatus_proxy_agent_connection_message = + "proxy connection summary is empty".to_string(); + } + let mut substatus_failed_auth_message: String; + if !proxy_agent_aggregate_status_top_level + .failedAuthenticateSummary + .is_empty() + { + let proxy_agent_aggregate_failed_auth_status_obj = get_top_proxy_connection_summary( + proxy_agent_aggregate_status_top_level + .failedAuthenticateSummary + .clone(), + constants::MAX_FAILED_AUTH_SUMMARY_LEN, + ); + match serde_json::to_string(&proxy_agent_aggregate_failed_auth_status_obj) { + Ok(proxy_agent_aggregate_failed_auth_status) => { + substatus_failed_auth_message = proxy_agent_aggregate_failed_auth_status; + } + Err(e) => { + let error_message = format!( + "Error in serializing proxy agent aggregate failed auth status: {e}" + ); + logger::write(error_message.to_string()); + substatus_failed_auth_message = error_message; } - } else { - logger::write("proxy failed auth summary is empty".to_string()); - substatus_failed_auth_message = "proxy failed auth summary is empty".to_string(); } + } else { + logger::write("proxy failed auth summary is empty".to_string()); + substatus_failed_auth_message = "proxy failed auth summary is empty".to_string(); + } - trim_proxy_agent_status_file( - &mut substatus_failed_auth_message, - &mut substatus_proxy_agent_connection_message, - constants::MAX_PROXYAGENT_CONNECTION_DATA_SIZE_IN_KB, - ); + trim_proxy_agent_status_file( + &mut substatus_failed_auth_message, + &mut substatus_proxy_agent_connection_message, + constants::MAX_PROXYAGENT_CONNECTION_DATA_SIZE_IN_KB, + ); - status.substatus = { - vec![ - SubStatus { - name: constants::PLUGIN_CONNECTION_NAME.to_string(), - status: constants::SUCCESS_STATUS.to_string(), - code: constants::STATUS_CODE_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: substatus_proxy_agent_connection_message.to_string(), - }, + status.substatus = { + vec![ + SubStatus { + name: constants::PLUGIN_CONNECTION_NAME.to_string(), + status: constants::SUCCESS_STATUS.to_string(), + code: constants::STATUS_CODE_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: substatus_proxy_agent_connection_message.to_string(), }, - SubStatus { - name: constants::PLUGIN_STATUS_NAME.to_string(), - status: constants::SUCCESS_STATUS.to_string(), - code: constants::STATUS_CODE_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: substatus_proxy_agent_message.to_string(), - }, + }, + SubStatus { + name: constants::PLUGIN_STATUS_NAME.to_string(), + status: constants::SUCCESS_STATUS.to_string(), + code: constants::STATUS_CODE_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: substatus_proxy_agent_message.to_string(), }, - SubStatus { - name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), - status: constants::SUCCESS_STATUS.to_string(), - code: constants::STATUS_CODE_OK, - formattedMessage: FormattedMessage { - lang: constants::LANG_EN_US.to_string(), - message: substatus_failed_auth_message.to_string(), - }, + }, + SubStatus { + name: constants::PLUGIN_FAILED_AUTH_NAME.to_string(), + status: constants::SUCCESS_STATUS.to_string(), + code: constants::STATUS_CODE_OK, + formattedMessage: FormattedMessage { + lang: constants::LANG_EN_US.to_string(), + message: substatus_failed_auth_message.to_string(), }, - ] - }; - status.status = status_state_obj.update_state(true); - status.configurationAppliedTime = misc_helpers::get_date_time_string(); - write_state_event( - constants::STATE_KEY_FILE_VERSION, - constants::SUCCESS_STATUS, - substatus_proxy_agent_connection_message.to_string(), - "extension_substatus", - "service_main", - &logger::get_logger_key(), - service_state, - ); - } + }, + ] + }; + status.status = status_state_obj.update_state(true); + status.configurationAppliedTime = misc_helpers::get_date_time_string(); + write_state_event( + constants::STATE_KEY_FILE_VERSION, + constants::SUCCESS_STATUS, + substatus_proxy_agent_connection_message.to_string(), + "extension_substatus", + "service_main", + &logger::get_logger_key(), + service_state, + ); } fn trim_proxy_agent_status_file( From 705a50ff0c251c5d1565e66ab091cca0a09b5929 Mon Sep 17 00:00:00 2001 From: Neerali Shah Date: Thu, 8 Jan 2026 13:59:31 -0800 Subject: [PATCH 8/8] lint --- proxy_agent_extension/src/service_main.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/proxy_agent_extension/src/service_main.rs b/proxy_agent_extension/src/service_main.rs index e9280b35..aeeac69a 100644 --- a/proxy_agent_extension/src/service_main.rs +++ b/proxy_agent_extension/src/service_main.rs @@ -432,11 +432,8 @@ fn report_error_status( use proxy_agent_shared::telemetry::event_logger; status.status = status_state_obj.update_state(false); - if service_state.update_service_state_entry( - error_key, - constants::ERROR_STATUS, - MAX_STATE_COUNT, - ) { + if service_state.update_service_state_entry(error_key, constants::ERROR_STATUS, MAX_STATE_COUNT) + { event_logger::write_event( LoggerLevel::Info, error_message.clone(), @@ -554,21 +551,18 @@ fn extension_substatus( ); match serde_json::to_string(&proxy_agent_aggregate_connection_status_obj) { Ok(proxy_agent_aggregate_connection_status) => { - substatus_proxy_agent_connection_message = - proxy_agent_aggregate_connection_status; + substatus_proxy_agent_connection_message = proxy_agent_aggregate_connection_status; } Err(e) => { - let error_message = format!( - "Error in serializing proxy agent aggregate connection status: {e}" - ); + let error_message = + format!("Error in serializing proxy agent aggregate connection status: {e}"); logger::write(error_message.to_string()); substatus_proxy_agent_connection_message = error_message; } } } else { logger::write("proxy connection summary is empty".to_string()); - substatus_proxy_agent_connection_message = - "proxy connection summary is empty".to_string(); + substatus_proxy_agent_connection_message = "proxy connection summary is empty".to_string(); } let mut substatus_failed_auth_message: String; if !proxy_agent_aggregate_status_top_level @@ -586,9 +580,8 @@ fn extension_substatus( substatus_failed_auth_message = proxy_agent_aggregate_failed_auth_status; } Err(e) => { - let error_message = format!( - "Error in serializing proxy agent aggregate failed auth status: {e}" - ); + let error_message = + format!("Error in serializing proxy agent aggregate failed auth status: {e}"); logger::write(error_message.to_string()); substatus_failed_auth_message = error_message; }