Zero downtime redeploys
When deploying check if there is already a container with the existing name. If there is rename it to "<version>_<random_hex_string>" to remove the name clash with the new container we want to boot. We can then do the normal zero downtime run/wait/stop. While implementing this I discovered the --filter name=foo does a substring match for foo, so I've updated those filters to do an exact match instead.
This commit is contained in:
@@ -76,7 +76,7 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
|
||||
test "stop with version" do
|
||||
assert_equal \
|
||||
"docker container ls --all --filter name=app-web-123 --quiet | xargs docker stop",
|
||||
"docker container ls --all --filter name=^app-web-123$ --quiet | xargs docker stop",
|
||||
new_command.stop(version: "123").join(" ")
|
||||
end
|
||||
|
||||
@@ -193,7 +193,7 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
|
||||
test "container_id_for" do
|
||||
assert_equal \
|
||||
"docker container ls --all --filter name=app-999 --quiet",
|
||||
"docker container ls --all --filter name=^app-999$ --quiet",
|
||||
new_command.container_id_for(container_name: "app-999").join(" ")
|
||||
end
|
||||
|
||||
@@ -224,14 +224,14 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
|
||||
test "remove_container" do
|
||||
assert_equal \
|
||||
"docker container ls --all --filter name=app-web-999 --quiet | xargs docker container rm",
|
||||
"docker container ls --all --filter name=^app-web-999$ --quiet | xargs docker container rm",
|
||||
new_command.remove_container(version: "999").join(" ")
|
||||
end
|
||||
|
||||
test "remove_container with destination" do
|
||||
@destination = "staging"
|
||||
assert_equal \
|
||||
"docker container ls --all --filter name=app-web-staging-999 --quiet | xargs docker container rm",
|
||||
"docker container ls --all --filter name=^app-web-staging-999$ --quiet | xargs docker container rm",
|
||||
new_command.remove_container(version: "999").join(" ")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user