Ensure kamal remove completes without setup
If `kamal setup` has not run or errored out part way through, `kamal remove` should still complete. Fixes: https://github.com/basecamp/kamal/issues/629
This commit is contained in:
@@ -20,7 +20,7 @@ class Kamal::Cli::Traefik < Kamal::Cli::Base
|
|||||||
on(hosts) do
|
on(hosts) do
|
||||||
execute *KAMAL.auditor.record("Rebooted traefik"), verbosity: :debug
|
execute *KAMAL.auditor.record("Rebooted traefik"), verbosity: :debug
|
||||||
execute *KAMAL.registry.login
|
execute *KAMAL.registry.login
|
||||||
execute *KAMAL.traefik.stop
|
execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false
|
||||||
execute *KAMAL.traefik.remove_container
|
execute *KAMAL.traefik.remove_container
|
||||||
execute *KAMAL.traefik.run
|
execute *KAMAL.traefik.run
|
||||||
end
|
end
|
||||||
@@ -44,7 +44,7 @@ class Kamal::Cli::Traefik < Kamal::Cli::Base
|
|||||||
mutating do
|
mutating do
|
||||||
on(KAMAL.traefik_hosts) do
|
on(KAMAL.traefik_hosts) do
|
||||||
execute *KAMAL.auditor.record("Stopped traefik"), verbosity: :debug
|
execute *KAMAL.auditor.record("Stopped traefik"), verbosity: :debug
|
||||||
execute *KAMAL.traefik.stop
|
execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,6 +60,19 @@ class MainTest < IntegrationTest
|
|||||||
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord"=>"/tmp/kamal-cord", "log_lines" => 50, "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
|
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord"=>"/tmp/kamal-cord", "log_lines" => 50, "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "setup and remove" do
|
||||||
|
# Check remove completes when nothing has been setup yet
|
||||||
|
kamal :remove, "-y"
|
||||||
|
assert_no_images_or_containers
|
||||||
|
|
||||||
|
kamal :envify
|
||||||
|
kamal :setup
|
||||||
|
assert_images_and_containers
|
||||||
|
|
||||||
|
kamal :remove, "-y"
|
||||||
|
assert_no_images_or_containers
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def assert_local_env_file(contents)
|
def assert_local_env_file(contents)
|
||||||
assert_equal contents, deployer_exec("cat .env", capture: true)
|
assert_equal contents, deployer_exec("cat .env", capture: true)
|
||||||
@@ -84,4 +97,22 @@ class MainTest < IntegrationTest
|
|||||||
|
|
||||||
assert_equal "200", Net::HTTP.get_response(URI.parse("http://localhost:12345/versions/.hidden")).code
|
assert_equal "200", Net::HTTP.get_response(URI.parse("http://localhost:12345/versions/.hidden")).code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def vm1_image_ids
|
||||||
|
docker_compose("exec vm1 docker image ls -q", capture: true).strip.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def vm1_container_ids
|
||||||
|
docker_compose("exec vm1 docker ps -a -q", capture: true).strip.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_no_images_or_containers
|
||||||
|
assert vm1_image_ids.empty?
|
||||||
|
assert vm1_container_ids.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_images_and_containers
|
||||||
|
assert vm1_image_ids.any?
|
||||||
|
assert vm1_container_ids.any?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user