From dadac999d76c7116509689b1da33e45f0ae22285 Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Fri, 27 Sep 2024 17:45:35 +0400 Subject: [PATCH 1/3] Fixed kamal-proxy remove call --- lib/kamal/cli/app.rb | 2 +- lib/kamal/commands/app/proxy.rb | 4 ++-- lib/kamal/configuration/proxy.rb | 4 ---- test/commands/app_test.rb | 4 ++-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/kamal/cli/app.rb b/lib/kamal/cli/app.rb index 7c77a7cf..98a08f7d 100644 --- a/lib/kamal/cli/app.rb +++ b/lib/kamal/cli/app.rb @@ -68,7 +68,7 @@ class Kamal::Cli::App < Kamal::Cli::Base version = capture_with_info(*app.current_running_version, raise_on_non_zero_exit: false).strip endpoint = capture_with_info(*app.container_id_for_version(version)).strip if endpoint.present? - execute *app.remove(target: endpoint), raise_on_non_zero_exit: false + execute *app.remove, raise_on_non_zero_exit: false end end diff --git a/lib/kamal/commands/app/proxy.rb b/lib/kamal/commands/app/proxy.rb index 550e2e3b..777a4aaf 100644 --- a/lib/kamal/commands/app/proxy.rb +++ b/lib/kamal/commands/app/proxy.rb @@ -5,8 +5,8 @@ module Kamal::Commands::App::Proxy proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target) end - def remove(target:) - proxy_exec :remove, role.container_prefix, *role.proxy.remove_command_args(target: target) + def remove + proxy_exec :remove, role.container_prefix end private diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index af09e2c7..7c40a6b3 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -51,10 +51,6 @@ class Kamal::Configuration::Proxy optionize ({ target: "#{target}:#{app_port}" }).merge(deploy_options) end - def remove_command_args(target:) - optionize({ target: "#{target}:#{app_port}" }) - end - def merge(other) self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config) end diff --git a/test/commands/app_test.rb b/test/commands/app_test.rb index 6704adb6..df11287e 100644 --- a/test/commands/app_test.rb +++ b/test/commands/app_test.rb @@ -121,8 +121,8 @@ class CommandsAppTest < ActiveSupport::TestCase test "remove" do assert_equal \ - "docker exec kamal-proxy kamal-proxy remove app-web --target \"172.1.0.2:80\"", - new_command.remove(target: "172.1.0.2").join(" ") + "docker exec kamal-proxy kamal-proxy remove app-web", + new_command.remove.join(" ") end From 472d163cc7be909514c96000260c48fa623a45d8 Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Fri, 27 Sep 2024 19:15:42 +0400 Subject: [PATCH 2/3] Assert 404 after app is stopped --- test/integration/app_test.rb | 2 +- test/integration/integration_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/app_test.rb b/test/integration/app_test.rb index 40a896b1..7112be9e 100644 --- a/test/integration/app_test.rb +++ b/test/integration/app_test.rb @@ -8,7 +8,7 @@ class AppTest < IntegrationTest kamal :app, :stop - assert_app_is_down + assert_app_not_found kamal :app, :start diff --git a/test/integration/integration_test.rb b/test/integration/integration_test.rb index ad99f3e2..e4dceb29 100644 --- a/test/integration/integration_test.rb +++ b/test/integration/integration_test.rb @@ -50,6 +50,12 @@ class IntegrationTest < ActiveSupport::TestCase assert_equal "502", response.code end + def assert_app_not_found + response = app_response + debug_response_code(response, "404") + assert_equal "404", response.code + end + def assert_app_is_up(version: nil, app: @app) response = app_response(app: app) debug_response_code(response, "200") From 6d63c4e9c6c08907e96aa296bdad10469081070e Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Fri, 27 Sep 2024 21:11:51 +0400 Subject: [PATCH 3/3] Fixed example with the proxy status after the application has been removed --- test/integration/app_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/app_test.rb b/test/integration/app_test.rb index 7112be9e..039ef012 100644 --- a/test/integration/app_test.rb +++ b/test/integration/app_test.rb @@ -48,7 +48,7 @@ class AppTest < IntegrationTest kamal :app, :remove - assert_app_is_down + assert_app_not_found assert_app_directory_removed end end