Browse Source

fix: stop/logs use CLI recipe name, health uses correct label filter

- Fix main.rs: stop and logs commands were passing recipe.name
  (human-readable, with spaces) instead of the directory name
  (CLI argument). Container labels use the directory name, so
  stop/logs couldn't find containers whose recipe name contained
  spaces.
- Fix health check: use --filter label=sm121.recipe (matches our
  actual label key) instead of --filter label=sm121 (which matches
  label key 'sm121' exactly — we use 'sm121.recipe').
Alexander Korolev 4 months ago
parent
commit
8194da83d4
3 changed files with 13 additions and 8 deletions
  1. 1 1
      recipes/test-sleep/recipe.toml
  2. 1 1
      src/docker/mod.rs
  3. 11 6
      src/main.rs

+ 1 - 1
recipes/test-sleep/recipe.toml

@@ -4,7 +4,7 @@ docker_image = "alpine:latest"
 model = "noop"
 port = 8000
 
-entrypoint = ["sh", "-c", "'sleep 180'"]
+entrypoint = ["sh", "-c", "'echo started && sleep 180 && echo completed'"]
 
 args = []
 

+ 1 - 1
src/docker/mod.rs

@@ -160,7 +160,7 @@ pub async fn health_check(config: &Config, cluster: &Cluster, dry_run: bool) ->
             let result = run_ssh_with_retry(
                 &config,
                 &node,
-                "docker ps --format '{{.Names}}\t{{.Status}}\t{{.Image}}' 2>&1; echo '---SM121---'; docker ps --filter label=sm121 --format '{{.Names}}' 2>&1"
+                "docker ps --format '{{.Names}}\t{{.Status}}\t{{.Image}}' 2>&1; echo '---SM121---'; docker ps --filter label=sm121.recipe --format '{{.Names}}' 2>&1"
                     .to_string(),
                 dry,
                 1,

+ 11 - 6
src/main.rs

@@ -30,13 +30,18 @@ async fn main() -> Result<()> {
         } => {
             docker::serve(&config, &recipe, &cluster, keep, dry_run).await?;
         }
-        Commands::Logs { recipe, follow } => {
-            let (cluster, recipe) = resolve_cluster_for_recipe(&config, &recipe).await?;
-            docker::show_logs(&config, &cluster, &recipe.name, follow, dry_run).await?;
+        Commands::Logs {
+            recipe: recipe_name,
+            follow,
+        } => {
+            let (cluster, _recipe) = resolve_cluster_for_recipe(&config, &recipe_name).await?;
+            docker::show_logs(&config, &cluster, &recipe_name, follow, dry_run).await?;
         }
-        Commands::Stop { recipe } => {
-            let (cluster, recipe) = resolve_cluster_for_recipe(&config, &recipe).await?;
-            docker::stop_cluster(&config, &cluster, &recipe.name, dry_run).await?;
+        Commands::Stop {
+            recipe: recipe_name,
+        } => {
+            let (cluster, _recipe) = resolve_cluster_for_recipe(&config, &recipe_name).await?;
+            docker::stop_cluster(&config, &cluster, &recipe_name, dry_run).await?;
         }
         Commands::Health {
             cluster: cluster_name,