@@ -182,6 +182,12 @@ struct BackgroundTasksShowArgs {
182
182
/// "all", "dns_external", or "dns_internal".
183
183
#[ clap( value_name = "TASK_NAME" ) ]
184
184
tasks : Vec < String > ,
185
+
186
+ /// Do not display information about whether a task is currently executing.
187
+ ///
188
+ /// Useful for test output stability.
189
+ #[ clap( long) ]
190
+ no_executing_info : bool ,
185
191
}
186
192
187
193
#[ derive( Debug , Args ) ]
@@ -906,6 +912,10 @@ async fn cmd_nexus_background_tasks_show(
906
912
} ) ;
907
913
}
908
914
915
+ let opts = BackgroundTasksPrintOpts {
916
+ show_executing_info : !args. no_executing_info ,
917
+ } ;
918
+
909
919
// Some tasks should be grouped and printed together in a certain order,
910
920
// even though their names aren't alphabetical. Notably, the DNS tasks
911
921
// logically go from config -> servers -> propagation, so we want to print
@@ -923,14 +933,14 @@ async fn cmd_nexus_background_tasks_show(
923
933
"blueprint_executor" ,
924
934
] {
925
935
if let Some ( bgtask) = tasks. remove ( name) {
926
- print_task ( & bgtask) ;
936
+ print_task ( & bgtask, & opts ) ;
927
937
} else if selected_all {
928
938
eprintln ! ( "warning: expected to find background task {:?}" , name) ;
929
939
}
930
940
}
931
941
932
942
for ( _, bgtask) in & tasks {
933
- print_task ( bgtask) ;
943
+ print_task ( bgtask, & opts ) ;
934
944
}
935
945
936
946
Ok ( ( ) )
@@ -999,32 +1009,39 @@ async fn cmd_nexus_background_tasks_activate(
999
1009
Ok ( ( ) )
1000
1010
}
1001
1011
1002
- fn print_task ( bgtask : & BackgroundTask ) {
1012
+ #[ derive( Clone , Debug ) ]
1013
+ struct BackgroundTasksPrintOpts {
1014
+ show_executing_info : bool ,
1015
+ }
1016
+
1017
+ fn print_task ( bgtask : & BackgroundTask , opts : & BackgroundTasksPrintOpts ) {
1003
1018
println ! ( "task: {:?}" , bgtask. name) ;
1004
1019
println ! (
1005
1020
" configured period: every {}" ,
1006
1021
humantime:: format_duration( bgtask. period. clone( ) . into( ) )
1007
1022
) ;
1008
- print ! ( " currently executing: " ) ;
1009
- match & bgtask. current {
1010
- CurrentStatus :: Idle => println ! ( "no" ) ,
1011
- CurrentStatus :: Running ( current) => {
1012
- let elapsed = std:: time:: SystemTime :: from ( current. start_time )
1013
- . elapsed ( )
1014
- . map ( |s| format ! ( "{:.3}ms" , s. as_millis( ) ) )
1015
- . unwrap_or_else ( |error| format ! ( "(unknown: {:#})" , error) ) ;
1016
- print ! (
1017
- "iter {}, triggered by {}\n " ,
1018
- current. iteration,
1019
- reason_str( & current. reason)
1020
- ) ;
1021
- print ! (
1022
- " started at {}, running for {}\n " ,
1023
- humantime:: format_rfc3339_millis( current. start_time. into( ) ) ,
1024
- elapsed,
1025
- ) ;
1023
+ if opts. show_executing_info {
1024
+ print ! ( " currently executing: " ) ;
1025
+ match & bgtask. current {
1026
+ CurrentStatus :: Idle => println ! ( "no" ) ,
1027
+ CurrentStatus :: Running ( current) => {
1028
+ let elapsed = std:: time:: SystemTime :: from ( current. start_time )
1029
+ . elapsed ( )
1030
+ . map ( |s| format ! ( "{:.3}ms" , s. as_millis( ) ) )
1031
+ . unwrap_or_else ( |error| format ! ( "(unknown: {:#})" , error) ) ;
1032
+ print ! (
1033
+ "iter {}, triggered by {}\n " ,
1034
+ current. iteration,
1035
+ reason_str( & current. reason)
1036
+ ) ;
1037
+ print ! (
1038
+ " started at {}, running for {}\n " ,
1039
+ humantime:: format_rfc3339_millis( current. start_time. into( ) ) ,
1040
+ elapsed,
1041
+ ) ;
1042
+ }
1026
1043
}
1027
- } ;
1044
+ }
1028
1045
1029
1046
print ! ( " last completed activation: " ) ;
1030
1047
match & bgtask. last {
0 commit comments