@@ -2546,9 +2546,8 @@ impl TerminateContainer {
2546
2546
2547
2547
async fn terminate_now ( & mut self ) -> Result < ( ) , TerminateContainerError > {
2548
2548
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) ;
2552
2551
}
2553
2552
2554
2553
Ok ( ( ) )
@@ -2563,14 +2562,30 @@ impl TerminateContainer {
2563
2562
kill_child
2564
2563
} )
2565
2564
}
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
+ }
2566
2581
}
2567
2582
2568
2583
impl Drop for TerminateContainer {
2569
2584
fn drop ( & mut self ) {
2570
2585
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}" ) ,
2574
2589
}
2575
2590
}
2576
2591
}
0 commit comments