File tree Expand file tree Collapse file tree 3 files changed +22
-13
lines changed
Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 22
33## Changed
44
5- - Variety of minor cleanups
5+ - Better handling of Ctrl-C on the inject command
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ members = ["fault-cli", "fault-ebpf-programs"]
44default-members = [" fault-cli" ]
55
66[workspace .package ]
7- version = " 0.11.0 "
7+ version = " 0.11.1 "
88edition = " 2024"
99rust-version = " 1.85"
1010license-file = " LICENSE"
Original file line number Diff line number Diff line change @@ -833,24 +833,33 @@ pub async fn run_fault_injector_roundtrip<P: Platform>(
833833 svc. name. yellow( )
834834 ) ;
835835
836- if let Some ( duration ) = duration {
837- match parse_duration:: parse ( duration . as_str ( ) ) {
836+ match duration {
837+ Some ( d ) => match parse_duration:: parse ( d . as_str ( ) ) {
838838 Ok ( total) => {
839- println ! ( " Injecting fault for {}" , duration) ;
840- sleep ( total) . await
839+ println ! ( " Injecting fault for {}" , d) ;
840+ tokio:: select! {
841+ _ = tokio:: signal:: ctrl_c( ) => {
842+ tracing:: info!( "Shutdown signal received. Initiating shutdown." ) ;
843+ }
844+
845+ _ = sleep( total) => {
846+ tracing:: info!( "Time's up! Shutting down now." ) ;
847+ }
848+ }
841849 }
842850 Err ( _) => anyhow:: bail!( "failed to parse the duration flag" ) ,
851+ } ,
852+ None => {
853+ let _ = Confirm :: new ( & format ! (
854+ "Press '{}' to finish and rollback" ,
855+ "y" . to_string( ) . green( )
856+ ) )
857+ . prompt ( ) ;
843858 }
844- } else {
845- let _ = Confirm :: new ( & format ! (
846- "Press '{}' to finish and rollback" ,
847- "y" . to_string( ) . green( )
848- ) )
849- . prompt ( ) ;
850859 }
851860
852- plt. rollback ( ) . await ?;
853861 println ! ( " Rolling back fault..." ) ;
862+ plt. rollback ( ) . await ?;
854863 //plt.wait_cleanup().await?;
855864 println ! ( " Rolled back." ) ;
856865
You can’t perform that action at this time.
0 commit comments