Record bounded session/channel close diagnostics on agent and gateway
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -2546,7 +2546,9 @@ fn service_run(stop: &'static AtomicBool) -> Result<()> {
|
||||
continue;
|
||||
}
|
||||
let start = Instant::now();
|
||||
let _ = agent.session(stop).await;
|
||||
if let Err(error) = agent.session(stop).await {
|
||||
record_session_error(&agent.config.state_directory, &error);
|
||||
}
|
||||
if start.elapsed() > Duration::from_secs(60) {
|
||||
backoff = 1;
|
||||
}
|
||||
@@ -2611,6 +2613,14 @@ pub fn main() -> Result<()> {
|
||||
rmm_agent_windows::service::dispatch(service_run)
|
||||
}
|
||||
|
||||
/// Operator diagnostics only: the bounded error chain of the last session end
|
||||
/// in the agent's own private state directory. Never authority or retry input.
|
||||
fn record_session_error(state: &Path, error: &anyhow::Error) {
|
||||
let mut text = format!("{error:#}");
|
||||
text.truncate(1024);
|
||||
let value = serde_json::json!({"schema_version":1,"observed_at_utc":Utc::now(),"error":text});
|
||||
let _ = std::fs::write(state.join("session-last-error.json"), value.to_string());
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -102,10 +102,9 @@ pub async fn connect(
|
||||
.max_message_size(MAX_MESSAGE)
|
||||
.max_frame_size(MAX_MESSAGE)
|
||||
.on_upgrade(move |mut socket| async move {
|
||||
if channel(&state, &mut socket, tenant, agent, expires)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
if let Err(error) = channel(&state, &mut socket, tenant, agent, expires).await {
|
||||
// Operator diagnostics only: the bounded error chain, no payloads or keys.
|
||||
eprintln!("WSS_CHANNEL_CLOSED agent={agent} error={error:#}");
|
||||
let _ = socket.send(Message::Close(None)).await;
|
||||
}
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user