Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add timestamped downloading decision line to seed deploy log

sow-116

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+47 -9
+8 -6
apps/garden/lib/garden/deployer.ex
··· 87 87 artifact: seed.artifact 88 88 ) 89 89 90 + downloading_line = decision_line("downloading #{seed.name} (#{seed.seed_type})") 90 91 report_seed_status_fun.(deployment, seed, :downloading) 91 - realize_seed_fun.(seed_deploy) 92 + {downloading_line, realize_seed_fun.(seed_deploy)} 92 93 end) 93 94 |> async_stream_fun.(fn 94 - {:ok, {:ok, %SeedDeployment{seed: seed} = seed_deploy, download_output}} -> 95 + {:ok, {downloading_line, {:ok, %SeedDeployment{seed: seed} = seed_deploy, download_output}}} -> 95 96 profile = get_deployment_profile_fun.(seed_deploy.subscription_sid) 96 97 mode = Garden.Seed.activation_mode(profile) 97 98 98 99 preamble = 99 - download_output ++ 100 + [downloading_line | download_output] ++ 100 101 [ 101 102 decision_line("realized #{seed.name} (#{seed.seed_type})"), 102 103 decision_line("activating #{seed.name} (#{seed.seed_type}) with mode: #{mode}") ··· 160 161 result 161 162 162 163 {:ok, 163 - {:error, :failed_to_realize, %SeedDeployment{seed: seed} = _seed_deploy, download_output}} -> 164 + {downloading_line, 165 + {:error, :failed_to_realize, %SeedDeployment{seed: seed} = _seed_deploy, download_output}}} -> 164 166 report_seed_result_fun.( 165 167 deployment, 166 168 seed, 167 169 :failure, 168 - download_output ++ 170 + [downloading_line | download_output] ++ 169 171 [ 170 172 decision_line("realization failed for #{seed.name} (#{seed.seed_type})") 171 173 ] ··· 173 175 174 176 {:error, :failed_to_realize, seed} 175 177 176 - {:ok, {:error, _, _} = error} -> 178 + {:ok, {_downloading_line, {:error, _, _} = error}} -> 177 179 error 178 180 179 181 {:exit, error} ->
+39 -3
apps/garden/test/garden/deployer_test.exs
··· 498 498 assert Enum.any?(reboot_lines, &(&1 =~ "[garden]" and &1 =~ "reboot skipped")) 499 499 end 500 500 501 + test "includes downloading decision line before download output" do 502 + deployment = %Deployment{ 503 + sid: "dep_dl_start", 504 + seed_deployments: [seed_deploy_with_identity("seed_ds1")] 505 + } 506 + 507 + download_lines = ["copying path '/nix/store/abc123'"] 508 + 509 + logged_lines = 510 + capture_seed_result_lines(deployment, 511 + realize_seed_fun: fn sd -> {:ok, sd, download_lines} end 512 + ) 513 + 514 + assert Enum.at(logged_lines, 0) =~ "[garden]" 515 + assert Enum.at(logged_lines, 0) =~ "downloading seed-seed_ds1 (nixos)" 516 + assert Enum.at(logged_lines, 1) == "copying path '/nix/store/abc123'" 517 + end 518 + 519 + test "includes downloading decision line in failure log" do 520 + deployment = %Deployment{ 521 + sid: "dep_dl_start_fail", 522 + seed_deployments: [seed_deploy_with_identity("seed_dsf1")] 523 + } 524 + 525 + download_lines = ["error: path '/nix/store/missing' is not valid"] 526 + 527 + logged_lines = 528 + capture_seed_result_lines(deployment, 529 + realize_seed_fun: fn sd -> {:error, :failed_to_realize, sd, download_lines} end 530 + ) 531 + 532 + assert Enum.at(logged_lines, 0) =~ "[garden]" 533 + assert Enum.at(logged_lines, 0) =~ "downloading seed-seed_dsf1 (nixos)" 534 + assert Enum.at(logged_lines, 1) == "error: path '/nix/store/missing' is not valid" 535 + end 536 + 501 537 test "includes download output in log before decision lines" do 502 538 deployment = %Deployment{ 503 539 sid: "dep_dl_log", ··· 511 547 realize_seed_fun: fn sd -> {:ok, sd, download_lines} end 512 548 ) 513 549 514 - assert Enum.at(logged_lines, 0) == "copying path '/nix/store/abc123'" 515 - assert Enum.at(logged_lines, 1) == "copying path '/nix/store/def456'" 550 + assert Enum.at(logged_lines, 1) == "copying path '/nix/store/abc123'" 551 + assert Enum.at(logged_lines, 2) == "copying path '/nix/store/def456'" 516 552 assert Enum.any?(logged_lines, &(&1 =~ "[garden]" and &1 =~ "realized")) 517 553 end 518 554 ··· 529 565 realize_seed_fun: fn sd -> {:error, :failed_to_realize, sd, download_lines} end 530 566 ) 531 567 532 - assert Enum.at(logged_lines, 0) == "error: path '/nix/store/missing' is not valid" 568 + assert Enum.at(logged_lines, 1) == "error: path '/nix/store/missing' is not valid" 533 569 assert Enum.any?(logged_lines, &(&1 =~ "[garden]" and &1 =~ "realization failed")) 534 570 end 535 571