@@ -18,7 +18,7 @@ use scc::HashMap;
1818use universaldb:: prelude:: * ;
1919use vbare:: OwnedVersionedData ;
2020
21- use crate :: { metrics, utils:: UrlData } ;
21+ use crate :: { errors , metrics, utils:: UrlData } ;
2222
2323pub struct Conn {
2424 pub namespace_id : Id ,
@@ -54,6 +54,20 @@ pub async fn init_conn(
5454 . ok_or_else ( || namespace:: errors:: Namespace :: NotFound . build ( ) )
5555 . with_context ( || format ! ( "namespace not found: {}" , namespace_name) ) ?;
5656
57+ let pool_res = ctx
58+ . op ( pegboard:: ops:: runner_config:: get:: Input {
59+ runners : vec ! [ ( namespace. namespace_id, pool_name. clone( ) ) ] ,
60+ bypass_cache : false ,
61+ } )
62+ . await ?;
63+
64+ let Some ( pool) = pool_res. into_iter ( ) . next ( ) else {
65+ return Err ( errors:: WsError :: NoRunnerConfig {
66+ pool_name : pool_name. clone ( ) ,
67+ }
68+ . build ( ) ) ;
69+ } ;
70+
5771 tracing:: debug!( namespace_id=?namespace. namespace_id, "new envoy connection" ) ;
5872
5973 metrics:: CONNECTION_TOTAL
@@ -67,27 +81,20 @@ pub async fn init_conn(
6781 . with_label_values ( & [ namespace. namespace_id . to_string ( ) . as_str ( ) , & pool_name] )
6882 . observe ( start. elapsed ( ) . as_secs_f64 ( ) ) ;
6983
84+ let serverless_drain_grace_period = if let RunnerConfigKind :: Serverless {
85+ drain_grace_period,
86+ ..
87+ } = & pool. config . kind
88+ {
89+ Some ( * drain_grace_period as i64 )
90+ } else {
91+ None
92+ } ;
93+
7094 let udb = ctx. udb ( ) ?;
71- let ( is_serverless, mut missed_commands, _ ) = tokio:: try_join!(
95+ let ( is_serverless, mut missed_commands) = tokio:: try_join!(
7296 // Send init packet as soon as possible
7397 async {
74- let pool_res = ctx
75- . op( pegboard:: ops:: runner_config:: get:: Input {
76- runners: vec![ ( namespace. namespace_id, pool_name. clone( ) ) ] ,
77- bypass_cache: false ,
78- } )
79- . await ?;
80-
81- let serverless_drain_grace_period = pool_res. first( ) . and_then( |c| {
82- if let RunnerConfigKind :: Serverless {
83- drain_grace_period, ..
84- } = & c. config. kind
85- {
86- Some ( * drain_grace_period as i64 )
87- } else {
88- None
89- }
90- } ) ;
9198 let pb = ctx. config( ) . pegboard( ) ;
9299
93100 // Send init packet
@@ -279,12 +286,6 @@ pub async fn init_conn(
279286 }
280287 } )
281288 . custom_instrument( tracing:: info_span!( "envoy_init_tx" ) ) ,
282- ctx. op(
283- pegboard:: ops:: runner_config:: ensure_normal_if_missing:: Input {
284- namespace_id: namespace. namespace_id,
285- name: pool_name. clone( ) ,
286- }
287- ) ,
288289 ) ?;
289290
290291 // Send missed commands (must be after init packet)
0 commit comments