@@ -2546,9 +2546,8 @@ impl TerminateContainer {
25462546
25472547 async fn terminate_now ( & mut self ) -> Result < ( ) , TerminateContainerError > {
25482548 if let Some ( mut kill_child) = self . take_command ( ) {
2549- // [ALREADY-DEAD] We don't care if the command itself
2550- // succeeds or not; the container may already be dead!
2551- let _ = kill_child. status ( ) . await ?;
2549+ let o = kill_child. output ( ) . await ?;
2550+ Self :: report_failure ( o) ;
25522551 }
25532552
25542553 Ok ( ( ) )
@@ -2563,14 +2562,30 @@ impl TerminateContainer {
25632562 kill_child
25642563 } )
25652564 }
2565+
2566+ fn report_failure ( s : std:: process:: Output ) {
2567+ // We generally don't care if the command itself succeeds or
2568+ // not; the container may already be dead! However, let's log
2569+ // it in an attempt to debug cases where there are more
2570+ // containers running than we expect.
2571+
2572+ if !s. status . success ( ) {
2573+ let code = s. status . code ( ) ;
2574+ // FUTURE: use `_owned`
2575+ let stdout = String :: from_utf8_lossy ( & s. stdout ) ;
2576+ let stderr = String :: from_utf8_lossy ( & s. stderr ) ;
2577+
2578+ error ! ( ?code, %stdout, %stderr, "Killing the container failed" ) ;
2579+ }
2580+ }
25662581}
25672582
25682583impl Drop for TerminateContainer {
25692584 fn drop ( & mut self ) {
25702585 if let Some ( mut kill_child) = self . take_command ( ) {
2571- if let Err ( e ) = kill_child. as_std_mut ( ) . status ( ) {
2572- // See [ALREADY-DEAD]
2573- error ! ( "Unable to kill the container while dropping: {e}" ) ;
2586+ match kill_child. as_std_mut ( ) . output ( ) {
2587+ Ok ( o ) => Self :: report_failure ( o ) ,
2588+ Err ( e ) => error ! ( "Unable to kill the container while dropping: {e}" ) ,
25742589 }
25752590 }
25762591 }
0 commit comments