Переглянути джерело

fix: redirect stderr in `cargo run logs --follow` docker pipeline

The tail command already ended with `2>&1` so any docker logs error
or warning was captured.  The follow command did not, so docker's
own stderr ("Error: No such container", etc.) bypassed the launcher
output and was lost on the remote terminal.

Add the `2>&1` to `logs_follow_cmd` to match.  Test extended to
guard against the redirection being dropped again.
Alexander Korolev 4 місяців тому
батько
коміт
5097d55c77
2 змінених файлів з 7 додано та 1 видалено
  1. 1 1
      src/docker/mod.rs
  2. 6 0
      src/docker/tests.rs

+ 1 - 1
src/docker/mod.rs

@@ -72,7 +72,7 @@ pub(crate) fn logs_tail_cmd(recipe_name: &str, rank: u32, tail: usize) -> String
 /// container of `recipe_name` in real time.
 pub(crate) fn logs_follow_cmd(recipe_name: &str) -> String {
     format!(
-        "docker ps -q --filter \"label=sm121.recipe={}\" --filter \"label=sm121.rank=0\" | xargs -r docker logs -f --timestamps",
+        "docker ps -q --filter \"label=sm121.recipe={}\" --filter \"label=sm121.rank=0\" | xargs -r docker logs -f --timestamps 2>&1",
         recipe_name
     )
 }

+ 6 - 0
src/docker/tests.rs

@@ -342,6 +342,12 @@ fn logs_follow_cmd_format() {
     assert!(cmd.contains("--filter \"label=sm121.rank=0\""));
     // Follow should not include --tail (we want a live stream from now).
     assert!(!cmd.contains("--tail"));
+    // Follow must redirect stderr so docker's own errors are captured
+    // (mirrors the behaviour of logs_tail_cmd).
+    assert!(
+        cmd.contains("2>&1"),
+        "follow cmd must capture stderr, got: {cmd}"
+    );
 }
 
 // ── Shell quoting ─────────────────────────────────────────────