@@ -12,15 +12,34 @@ use smallvec::SmallVec;
1212use std:: collections:: HashMap ;
1313use std:: fmt:: Write ;
1414use std:: path:: Path ;
15+ #[ cfg( not( test) ) ]
16+ use std:: sync:: OnceLock ;
1517use std:: time:: Duration ;
1618use tracing:: debug;
1719
1820/// Maximum log file size (5MB, matching executor-main)
1921const MAX_LOG_SIZE : usize = 5 * 1024 * 1024 ;
2022const MAX_BUILD_LOG_SIZE : usize = 1_000_000 ;
21- const LOG_FILE_WAIT_TIMEOUT : Duration = Duration :: from_secs ( 1 ) ;
2223const LOG_FILE_WAIT_INTERVAL : Duration = Duration :: from_millis ( 25 ) ;
2324
25+ #[ cfg( not( test) ) ]
26+ fn log_file_wait_timeout ( ) -> Duration {
27+ static TIMEOUT : OnceLock < Duration > = OnceLock :: new ( ) ;
28+ * TIMEOUT . get_or_init ( || {
29+ let millis = std:: env:: var ( "URT_LOG_FILE_WAIT_MS" )
30+ . ok ( )
31+ . or_else ( || std:: env:: var ( "OPR_EXECUTOR_LOG_FILE_WAIT_MS" ) . ok ( ) )
32+ . and_then ( |value| value. parse :: < u64 > ( ) . ok ( ) )
33+ . unwrap_or ( 0 ) ;
34+ Duration :: from_millis ( millis)
35+ } )
36+ }
37+
38+ #[ cfg( test) ]
39+ fn log_file_wait_timeout ( ) -> Duration {
40+ Duration :: from_secs ( 1 )
41+ }
42+
2443/// Request to execute a function
2544#[ derive( Debug , Clone ) ]
2645pub struct ExecuteRequest {
@@ -308,11 +327,7 @@ impl RuntimeProtocol for V5Protocol {
308327}
309328
310329pub fn runtime_network_host ( runtime : & Runtime ) -> & str {
311- if runtime. hostname . trim ( ) . is_empty ( ) {
312- & runtime. name
313- } else {
314- & runtime. hostname
315- }
330+ & runtime. name
316331}
317332
318333/// Read log files from disk and clean up (matching executor-main behavior)
@@ -345,7 +360,12 @@ async fn read_log_files(runtime_name: &str, file_id: &str) -> (String, String) {
345360}
346361
347362async fn wait_for_log_file ( path : & Path ) {
348- let deadline = tokio:: time:: Instant :: now ( ) + LOG_FILE_WAIT_TIMEOUT ;
363+ let timeout = log_file_wait_timeout ( ) ;
364+ if timeout. is_zero ( ) {
365+ return ;
366+ }
367+
368+ let deadline = tokio:: time:: Instant :: now ( ) + timeout;
349369
350370 loop {
351371 if tokio:: fs:: try_exists ( path) . await . unwrap_or ( false )
@@ -493,7 +513,7 @@ mod tests {
493513 }
494514
495515 #[ test]
496- fn test_runtime_network_host_prefers_hostname ( ) {
516+ fn test_runtime_network_host_uses_container_name_even_when_hostname_exists ( ) {
497517 let runtime = Runtime {
498518 version : "v5" . to_string ( ) ,
499519 created : 0.0 ,
@@ -509,12 +529,9 @@ mod tests {
509529 authorization_header : "Basic dummy" . to_string ( ) ,
510530 } ;
511531
512- assert_eq ! (
513- runtime_network_host( & runtime) ,
514- "1ca14d56857971dfad412b32f66e6466"
515- ) ;
532+ assert_eq ! ( runtime_network_host( & runtime) , "exc1-myruntime123" ) ;
516533 let url = build_runtime_url ( runtime_network_host ( & runtime) , 3000 , "/" ) ;
517- assert_eq ! ( url, "http://1ca14d56857971dfad412b32f66e6466 :3000/" ) ;
534+ assert_eq ! ( url, "http://exc1-myruntime123 :3000/" ) ;
518535 }
519536
520537 #[ test]
0 commit comments