@@ -358,8 +358,17 @@ struct CheckEnvoyLivenessInput {
358358 envoy_key : String ,
359359}
360360
361+ #[ derive( Debug , Serialize , Deserialize ) ]
362+ struct CheckEnvoyLivenessOutput {
363+ expired : bool ,
364+ now : i64 ,
365+ }
366+
361367#[ activity( CheckEnvoyLiveness ) ]
362- async fn check_envoy_liveness ( ctx : & ActivityCtx , input : & CheckEnvoyLivenessInput ) -> Result < bool > {
368+ async fn check_envoy_liveness (
369+ ctx : & ActivityCtx ,
370+ input : & CheckEnvoyLivenessInput ,
371+ ) -> Result < CheckEnvoyLivenessOutput > {
363372 let state = ctx. state :: < State > ( ) ?;
364373 let envoy_lost_threshold = ctx. config ( ) . pegboard ( ) . envoy_lost_threshold ( ) ;
365374
@@ -378,7 +387,7 @@ async fn check_envoy_liveness(ctx: &ActivityCtx, input: &CheckEnvoyLivenessInput
378387 let now = util:: timestamp:: now ( ) ;
379388 let expired = last_ping_ts < now - envoy_lost_threshold;
380389
381- Ok ( expired)
390+ Ok ( CheckEnvoyLivenessOutput { expired, now } )
382391 } )
383392 . custom_instrument ( tracing:: info_span!( "actor_check_envoy_liveness_tx" ) )
384393 . await
@@ -392,7 +401,7 @@ async fn listen_for_signals(
392401 metrics_workflow_id : Id ,
393402) -> Result < Vec < Main > > {
394403 // Listen for signals based on transition
395- let signals = match & state. transition {
404+ let signals = match & mut state. transition {
396405 Transition :: Allocating {
397406 lost_timeout_ts, ..
398407 }
@@ -432,20 +441,22 @@ async fn listen_for_signals(
432441 // Listen for signals with periodic liveness check timeout
433442 let signals = ctx
434443 . listen_n_until :: < Main > (
435- last_liveness_check_ts + ctx. config ( ) . pegboard ( ) . envoy_lost_threshold ( ) ,
444+ * last_liveness_check_ts + ctx. config ( ) . pegboard ( ) . envoy_lost_threshold ( ) ,
436445 256 ,
437446 )
438447 . await ?;
439448
440449 // Perform liveness check
441450 if signals. is_empty ( ) {
442- let expired = ctx
451+ let res = ctx
443452 . activity ( CheckEnvoyLivenessInput {
444453 envoy_key : envoy. envoy_key . clone ( ) ,
445454 } )
446455 . await ?;
447456
448- if expired {
457+ * last_liveness_check_ts = res. now ;
458+
459+ if res. expired {
449460 vec ! [ Main :: Lost ( Lost {
450461 generation: state. generation,
451462 reason: LostReason :: EnvoyConnectionLost ,
0 commit comments