Upgrade on accessory hosts only with correct messages
This commit is contained in:
@@ -224,18 +224,14 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
|
|||||||
def upgrade(name)
|
def upgrade(name)
|
||||||
confirming "This will restart all accessories" do
|
confirming "This will restart all accessories" do
|
||||||
with_lock do
|
with_lock do
|
||||||
if options[:rolling]
|
host_groups = options[:rolling] ? KAMAL.accessory_hosts : [ KAMAL.accessory_hosts ]
|
||||||
KAMAL.accessory_hosts.each do |host|
|
host_groups.each do |hosts|
|
||||||
say "Upgrading accessories on #{host}...", :magenta
|
host_list = Array(hosts).join(",")
|
||||||
KAMAL.with_specific_hosts(host) do
|
KAMAL.with_specific_hosts(hosts) do
|
||||||
reboot name
|
say "Upgrading #{name} accessories on #{host_list}...", :magenta
|
||||||
end
|
reboot name
|
||||||
say "Upgraded accessories on #{host}...", :magenta
|
say "Upgraded #{name} accessories on #{host_list}...", :magenta
|
||||||
end
|
end
|
||||||
else
|
|
||||||
say "Upgrading accessories on all hosts...", :magenta
|
|
||||||
reboot name
|
|
||||||
say "Upgraded accessories on all hosts", :magenta
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|||||||
host_groups = options[:rolling] ? KAMAL.hosts : [ KAMAL.hosts ]
|
host_groups = options[:rolling] ? KAMAL.hosts : [ KAMAL.hosts ]
|
||||||
host_groups.each do |hosts|
|
host_groups.each do |hosts|
|
||||||
host_list = Array(hosts).join(",")
|
host_list = Array(hosts).join(",")
|
||||||
say "Upgrading proxy on #{host_list}..."
|
say "Upgrading proxy on #{host_list}...", :magenta
|
||||||
run_hook "pre-proxy-reboot", hosts: host_list
|
run_hook "pre-proxy-reboot", hosts: host_list
|
||||||
on(hosts) do |host|
|
on(hosts) do |host|
|
||||||
execute *KAMAL.auditor.record("Rebooted proxy"), verbosity: :debug
|
execute *KAMAL.auditor.record("Rebooted proxy"), verbosity: :debug
|
||||||
@@ -97,7 +97,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
run_hook "post-proxy-reboot", hosts: host_list
|
run_hook "post-proxy-reboot", hosts: host_list
|
||||||
say "Upgraded proxy on #{host_list}"
|
say "Upgraded proxy on #{host_list}", :magenta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Kamal::Commander::Specifics
|
|||||||
end
|
end
|
||||||
|
|
||||||
def accessory_hosts
|
def accessory_hosts
|
||||||
specific_hosts || config.accessories.flat_map(&:hosts)
|
config.accessories.flat_map(&:hosts) & specified_hosts
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -222,21 +222,21 @@ class CliAccessoryTest < CliTestCase
|
|||||||
|
|
||||||
test "upgrade" do
|
test "upgrade" do
|
||||||
run_command("upgrade", "-y", "all").tap do |output|
|
run_command("upgrade", "-y", "all").tap do |output|
|
||||||
assert_match "Upgrading accessories on all hosts...", output
|
assert_match "Upgrading all accessories on 1.1.1.3,1.1.1.1,1.1.1.2...", output
|
||||||
assert_match "docker network create kamal on 1.1.1.3", output
|
assert_match "docker network create kamal on 1.1.1.3", output
|
||||||
assert_match "docker container stop app-mysql on 1.1.1.3", output
|
assert_match "docker container stop app-mysql on 1.1.1.3", output
|
||||||
assert_match "docker run --name app-mysql --detach --restart unless-stopped --network kamal --log-opt max-size=\"10m\" --publish 3306:3306 --env MYSQL_ROOT_HOST="%" --env-file .kamal/apps/app/env/accessories/mysql.env --volume $PWD/app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf --volume $PWD/app-mysql/data:/var/lib/mysql --label service=\"app-mysql\" mysql:5.7 on 1.1.1.3", output
|
assert_match "docker run --name app-mysql --detach --restart unless-stopped --network kamal --log-opt max-size=\"10m\" --publish 3306:3306 --env MYSQL_ROOT_HOST="%" --env-file .kamal/apps/app/env/accessories/mysql.env --volume $PWD/app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf --volume $PWD/app-mysql/data:/var/lib/mysql --label service=\"app-mysql\" mysql:5.7 on 1.1.1.3", output
|
||||||
assert_match "Upgraded accessories on all hosts", output
|
assert_match "Upgraded all accessories on 1.1.1.3,1.1.1.1,1.1.1.2...", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "upgrade rolling" do
|
test "upgrade rolling" do
|
||||||
run_command("upgrade", "--rolling", "-y", "all").tap do |output|
|
run_command("upgrade", "--rolling", "-y", "all").tap do |output|
|
||||||
assert_match "Upgrading accessories on 1.1.1.3...", output
|
assert_match "Upgrading all accessories on 1.1.1.3...", output
|
||||||
assert_match "docker network create kamal on 1.1.1.3", output
|
assert_match "docker network create kamal on 1.1.1.3", output
|
||||||
assert_match "docker container stop app-mysql on 1.1.1.3", output
|
assert_match "docker container stop app-mysql on 1.1.1.3", output
|
||||||
assert_match "docker run --name app-mysql --detach --restart unless-stopped --network kamal --log-opt max-size=\"10m\" --publish 3306:3306 --env MYSQL_ROOT_HOST="%" --env-file .kamal/apps/app/env/accessories/mysql.env --volume $PWD/app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf --volume $PWD/app-mysql/data:/var/lib/mysql --label service=\"app-mysql\" mysql:5.7 on 1.1.1.3", output
|
assert_match "docker run --name app-mysql --detach --restart unless-stopped --network kamal --log-opt max-size=\"10m\" --publish 3306:3306 --env MYSQL_ROOT_HOST="%" --env-file .kamal/apps/app/env/accessories/mysql.env --volume $PWD/app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf --volume $PWD/app-mysql/data:/var/lib/mysql --label service=\"app-mysql\" mysql:5.7 on 1.1.1.3", output
|
||||||
assert_match "Upgraded accessories on 1.1.1.3", output
|
assert_match "Upgraded all accessories on 1.1.1.3", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ class CliMainTest < CliTestCase
|
|||||||
test "upgrade rolling" do
|
test "upgrade rolling" do
|
||||||
invoke_options = { "config_file" => "test/fixtures/deploy_with_accessories.yml", "skip_hooks" => false, "confirmed" => true, "rolling" => false }
|
invoke_options = { "config_file" => "test/fixtures/deploy_with_accessories.yml", "skip_hooks" => false, "confirmed" => true, "rolling" => false }
|
||||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:upgrade", [], invoke_options).times(4)
|
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:upgrade", [], invoke_options).times(4)
|
||||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:upgrade", [ "all" ], invoke_options).times(4)
|
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:upgrade", [ "all" ], invoke_options).times(3)
|
||||||
|
|
||||||
run_command("upgrade", "--rolling", "-y", config_file: "deploy_with_accessories").tap do |output|
|
run_command("upgrade", "--rolling", "-y", config_file: "deploy_with_accessories").tap do |output|
|
||||||
assert_match "Upgrading 1.1.1.1...", output
|
assert_match "Upgrading 1.1.1.1...", output
|
||||||
|
|||||||
Reference in New Issue
Block a user