From f7261e165bda87dae49c879bdac850479cc20c19 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 24 Sep 2022 23:37:23 +0200 Subject: detect bot crashes --- planetwars-matchrunner/src/docker_runner.rs | 5 +++-- planetwars-matchrunner/src/match_context.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'planetwars-matchrunner/src') diff --git a/planetwars-matchrunner/src/docker_runner.rs b/planetwars-matchrunner/src/docker_runner.rs index 939d734..a4415ca 100644 --- a/planetwars-matchrunner/src/docker_runner.rs +++ b/planetwars-matchrunner/src/docker_runner.rs @@ -207,8 +207,9 @@ impl DockerBotRunner { let result = timeout(request.timeout, resp_fut).await; let request_response = match result { Ok(Ok(response)) => Ok(response.to_vec()), - // this one happens when a bot output stream ends, map this to Timeout for now - Ok(Err(_read_error)) => Err(RequestError::Timeout), + // Read failed. + // TODO: better logging for errors + Ok(Err(_read_error)) => Err(RequestError::BotTerminated), Err(_elapsed) => Err(RequestError::Timeout), }; let request_id = (self.player_id, request.request_id); diff --git a/planetwars-matchrunner/src/match_context.rs b/planetwars-matchrunner/src/match_context.rs index bdc87a3..6e6a088 100644 --- a/planetwars-matchrunner/src/match_context.rs +++ b/planetwars-matchrunner/src/match_context.rs @@ -163,6 +163,7 @@ impl Future for Request { #[derive(Debug, Clone, PartialEq, Eq)] pub enum RequestError { Timeout, + BotTerminated, } pub type RequestResult = Result; -- cgit v1.2.3