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:
@@ -86,6 +86,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
docker :ps, "--quiet", *filter_args
|
||||
end
|
||||
|
||||
def container_id_for_version(version)
|
||||
container_id_for(container_name: container_name(version))
|
||||
end
|
||||
|
||||
def current_running_version
|
||||
# FIXME: Find more graceful way to extract the version from "app-version" than using sed and tail!
|
||||
pipe \
|
||||
@@ -108,6 +112,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
xargs(docker(:container, :rm))
|
||||
end
|
||||
|
||||
def rename_container(version:, new_version:)
|
||||
docker :rename, container_name(version), container_name(new_version)
|
||||
end
|
||||
|
||||
def remove_containers
|
||||
docker :container, :prune, "--force", *filter_args
|
||||
end
|
||||
@@ -126,10 +134,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
[ config.service, role, config.destination, version || config.version ].compact.join("-")
|
||||
end
|
||||
|
||||
def container_id_for_version(version)
|
||||
container_id_for(container_name: container_name(version))
|
||||
end
|
||||
|
||||
def filter_args
|
||||
argumentize "--filter", filters
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ module Mrsk::Commands
|
||||
end
|
||||
|
||||
def container_id_for(container_name:)
|
||||
docker :container, :ls, "--all", "--filter", "name=#{container_name}", "--quiet"
|
||||
docker :container, :ls, "--all", "--filter", "name=^#{container_name}$", "--quiet"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -43,7 +43,7 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base
|
||||
end
|
||||
|
||||
def container_id
|
||||
container_id_for(container_name: container_name)
|
||||
container_id_for(container_name: container_name_with_version)
|
||||
end
|
||||
|
||||
def health_url
|
||||
|
||||
@@ -26,7 +26,7 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
||||
end
|
||||
|
||||
def info
|
||||
docker :ps, "--filter", "name=traefik"
|
||||
docker :ps, "--filter", "name=^traefik$"
|
||||
end
|
||||
|
||||
def logs(since: nil, lines: nil, grep: nil)
|
||||
|
||||
Reference in New Issue
Block a user