From c51b48f7b0c76b787aa63592234d4359b9c41175 Mon Sep 17 00:00:00 2001 From: Echo Date: Tue, 5 May 2026 15:13:41 +0000 Subject: [PATCH] fix: ServiceStatusData deserialization mismatch with agent response Manager expected fields: name, status, healthy, uptime_secs Agent actually returns: name, display_name, active_state, sub_state, load_state, enabled_state, main_pid, healthy Updated ServiceStatusData to match agent response format. Updated health_check_poller.rs to use new field names. --- crates/pm-agent-client/src/types.rs | 16 ++++++++++++---- crates/pm-worker/src/health_check_poller.rs | 13 ++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/crates/pm-agent-client/src/types.rs b/crates/pm-agent-client/src/types.rs index 1b26da0..5d67ee8 100644 --- a/crates/pm-agent-client/src/types.rs +++ b/crates/pm-agent-client/src/types.rs @@ -202,12 +202,20 @@ pub struct AgentJobStatus { pub struct ServiceStatusData { /// Service name. pub name: String, - /// Service status string (e.g. `"running"`, `"stopped"`, `"failed"`). - pub status: String, + /// Human-readable service name. + pub display_name: String, + /// Active state (e.g. `"active"`, `"inactive"`, `"failed"`). + pub active_state: String, + /// Sub state (e.g. `"running"`, `"dead"`, `"exited"`). + pub sub_state: String, + /// Load state (e.g. `"loaded"`, `"not-found"`). + pub load_state: String, + /// Enabled state (e.g. `"enabled"`, `"disabled"`). + pub enabled_state: String, + /// Main PID of the service process. + pub main_pid: Option, /// Whether the service is considered healthy. pub healthy: bool, - /// Seconds elapsed since the service started (`null` if not running). - pub uptime_secs: Option, } // ============================================================ diff --git a/crates/pm-worker/src/health_check_poller.rs b/crates/pm-worker/src/health_check_poller.rs index fbae464..093b0e7 100644 --- a/crates/pm-worker/src/health_check_poller.rs +++ b/crates/pm-worker/src/health_check_poller.rs @@ -262,15 +262,18 @@ async fn run_service_check( Ok(data) => { let detail = if data.healthy { format!( - "Service '{}' is {} (uptime: {}s)", + "Service '{}' is {}/{} (enabled: {})", data.name, - data.status, - data.uptime_secs.map_or("N/A".to_string(), |s| s.to_string()) + data.active_state, + data.sub_state, + data.enabled_state ) } else { format!( - "Service '{}' status: {} (unhealthy)", - data.name, data.status + "Service '{}' status: {}/{} (unhealthy, enabled: {})", + data.name, data.active_state, + data.sub_state, + data.enabled_state ) }; (data.healthy, detail)