@@ -9,6 +9,13 @@ pub struct Input {
99 pub runners : Vec < ( Id , String ) > ,
1010}
1111
12+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
13+ struct RunnerPoolErrorCacheEntry {
14+ namespace_id : Id ,
15+ runner_name : String ,
16+ error : Option < RunnerPoolError > ,
17+ }
18+
1219#[ derive( Debug , Clone , Serialize , Deserialize ) ]
1320pub struct RunnerPoolErrorEntry {
1421 pub namespace_id : Id ,
@@ -25,7 +32,8 @@ pub async fn pegboard_runner_config_get_error(
2532 return Ok ( Vec :: new ( ) ) ;
2633 }
2734
28- ctx. cache ( )
35+ let entries = ctx
36+ . cache ( )
2937 . clone ( )
3038 . request ( )
3139 // Short TTL since errors can change quickly
@@ -43,13 +51,24 @@ pub async fn pegboard_runner_config_get_error(
4351 Ok ( cache)
4452 } ,
4553 )
46- . await
54+ . await ?
55+ . into_iter ( )
56+ . filter_map ( |entry| {
57+ entry. error . map ( |error| RunnerPoolErrorEntry {
58+ namespace_id : entry. namespace_id ,
59+ runner_name : entry. runner_name ,
60+ error,
61+ } )
62+ } )
63+ . collect ( ) ;
64+
65+ Ok ( entries)
4766}
4867
4968async fn runner_config_get_error_inner (
5069 ctx : & OperationCtx ,
5170 runners : Vec < ( Id , String ) > ,
52- ) -> Result < Vec < RunnerPoolErrorEntry > > {
71+ ) -> Result < Vec < RunnerPoolErrorCacheEntry > > {
5372 let queries: Vec < ( & str , serde_json:: Value ) > = runners
5473 . iter ( )
5574 . map ( |( namespace_id, runner_name) | {
@@ -108,13 +127,11 @@ async fn runner_config_get_error_inner(
108127 }
109128 } ;
110129
111- if let Some ( active_error) = & state. active_error {
112- result. push ( RunnerPoolErrorEntry {
113- namespace_id : * namespace_id,
114- runner_name : runner_name. clone ( ) ,
115- error : active_error. error . clone ( ) ,
116- } ) ;
117- }
130+ result. push ( RunnerPoolErrorCacheEntry {
131+ namespace_id : * namespace_id,
132+ runner_name : runner_name. clone ( ) ,
133+ error : state. active_error . as_ref ( ) . map ( |err| err. error . clone ( ) ) ,
134+ } ) ;
118135 }
119136
120137 Ok ( result)
0 commit comments