kamal 1.8.3 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67aa8d9022e0dd44e1be0a0ab8c26f20dd458fb469cf5e9d461dd58871712d8d
4
- data.tar.gz: 286d81788711c43f783e7a4bebc861bf89eeb948f7bebb622686e9947151296d
3
+ metadata.gz: 7d09c1f0d8df9701e126a4c0f806ca07077ce110198e0f2e1af29bd44777fccc
4
+ data.tar.gz: bfc5b1313e0da24ae3e5ab00bf46da27100c81d9476ae3130903d98870480778
5
5
  SHA512:
6
- metadata.gz: dad7512c1f60ab760bb4cbe5183f8af92b8388697d7778fef2def69bed50be1e90befa09e765e30ad60af58548db69e8184df82053c6f9c1c28e3fa1549373de
7
- data.tar.gz: 75b5950ba4d744e9c7040c0531efcc2c781d13b1910d14226f6241424a6aba87aa0b24dcc249e13248f9c6da64fe2248fadffffbda630033a71ba78a2b3dd4c6
6
+ metadata.gz: bab2487f89e87f0ffd9da8f9e106db29ca6e373ca9bd45de4234f11864c04b9e7ce5c7cc68bacbdcc74e6a1f22e5c2542fee1647c4ab8102087366e83bd9d0e2
7
+ data.tar.gz: 50336374e58077f4d60ef074e8d247f2981d6aca032ab781e0116936e5a7353ad95b925b2ed9bac3d7111d9aecd6d4c2f79167ac920640cf88352accd467258d
@@ -222,6 +222,25 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
222
222
  end
223
223
  end
224
224
 
225
+ desc "downgrade", "Downgrade accessories from Kamal 2 to 1.9"
226
+ option :rolling, type: :boolean, default: false, desc: "Upgrade one host at a time"
227
+ option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
228
+ def downgrade(name)
229
+ confirming "This will restart all accessories" do
230
+ with_lock do
231
+ host_groups = options[:rolling] ? KAMAL.accessory_hosts : [ KAMAL.accessory_hosts ]
232
+ host_groups.each do |hosts|
233
+ host_list = Array(hosts).join(",")
234
+ KAMAL.with_specific_hosts(hosts) do
235
+ say "Downgrading #{name} accessories on #{host_list}...", :magenta
236
+ reboot name
237
+ say "Downgraded #{name} accessories on #{host_list}...", :magenta
238
+ end
239
+ end
240
+ end
241
+ end
242
+ end
243
+
225
244
  private
226
245
  def with_accessory(name)
227
246
  if KAMAL.config.accessory(name)
@@ -206,6 +206,10 @@ module Kamal::Cli
206
206
  instance_variable_get("@_invocations").first
207
207
  end
208
208
 
209
+ def reset_invocation(cli_class)
210
+ instance_variable_get("@_invocations")[cli_class].pop
211
+ end
212
+
209
213
  def ensure_run_and_locks_directory
210
214
  on(KAMAL.hosts) do
211
215
  execute(*KAMAL.server.ensure_run_directory)
@@ -217,6 +217,37 @@ class Kamal::Cli::Main < Kamal::Cli::Base
217
217
  end
218
218
  end
219
219
 
220
+ desc "downgrade", "Downgrade from Kamal 2 to 1.9"
221
+ option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
222
+ option :rolling, type: :boolean, default: false, desc: "Downgrade one host at a time"
223
+ def downgrade
224
+ confirming "This will replace Traefik with kamal-proxy and restart all accessories" do
225
+ with_lock do
226
+ if options[:rolling]
227
+ (KAMAL.hosts | KAMAL.accessory_hosts).each do |host|
228
+ KAMAL.with_specific_hosts(host) do
229
+ say "Downgrading #{host}...", :magenta
230
+ if KAMAL.hosts.include?(host)
231
+ invoke "kamal:cli:traefik:downgrade", [], options.merge(confirmed: true, rolling: false)
232
+ reset_invocation(Kamal::Cli::Traefik)
233
+ end
234
+ if KAMAL.accessory_hosts.include?(host)
235
+ invoke "kamal:cli:accessory:downgrade", [ "all" ], options.merge(confirmed: true, rolling: false)
236
+ reset_invocation(Kamal::Cli::Accessory)
237
+ end
238
+ say "Downgraded #{host}", :magenta
239
+ end
240
+ end
241
+ else
242
+ say "Downgrading all hosts...", :magenta
243
+ invoke "kamal:cli:traefik:downgrade", [], options.merge(confirmed: true)
244
+ invoke "kamal:cli:accessory:downgrade", [ "all" ], options.merge(confirmed: true)
245
+ say "Downgraded all hosts", :magenta
246
+ end
247
+ end
248
+ end
249
+ end
250
+
220
251
  desc "version", "Show Kamal version"
221
252
  def version
222
253
  puts Kamal::VERSION
@@ -119,4 +119,44 @@ class Kamal::Cli::Traefik < Kamal::Cli::Base
119
119
  end
120
120
  end
121
121
  end
122
+
123
+ desc "downgrade", "Downgrade to Traefik on servers (stop container, remove container, start new container, reboot app)"
124
+ option :rolling, type: :boolean, default: false, desc: "Reboot proxy on hosts in sequence, rather than in parallel"
125
+ option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
126
+ def downgrade
127
+ invoke_options = { "version" => KAMAL.config.latest_tag }.merge(options)
128
+
129
+ confirming "This will cause a brief outage on each host. Are you sure?" do
130
+ host_groups = options[:rolling] ? KAMAL.hosts : [ KAMAL.hosts ]
131
+ host_groups.each do |hosts|
132
+ host_list = Array(hosts).join(",")
133
+ say "Downgrading to Traefik on #{host_list}...", :magenta
134
+ run_hook "pre-traefik-reboot", hosts: host_list
135
+ on(hosts) do |host|
136
+ execute *KAMAL.auditor.record("Rebooted Traefik"), verbosity: :debug
137
+ execute *KAMAL.registry.login
138
+
139
+ "Stopping and removing kamal-proxy on #{host}, if running..."
140
+ execute *KAMAL.traefik.cleanup_kamal_proxy
141
+
142
+ "Stopping and removing Traefik on #{host}, if running..."
143
+ execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false
144
+ execute *KAMAL.traefik.remove_container
145
+ execute *KAMAL.traefik.remove_image
146
+ end
147
+
148
+ KAMAL.with_specific_hosts(hosts) do
149
+ invoke "kamal:cli:traefik:boot", [], invoke_options
150
+ reset_invocation(Kamal::Cli::Traefik)
151
+ invoke "kamal:cli:app:boot", [], invoke_options
152
+ reset_invocation(Kamal::Cli::App)
153
+ invoke "kamal:cli:prune:all", [], invoke_options
154
+ reset_invocation(Kamal::Cli::Prune)
155
+ end
156
+
157
+ run_hook "post-traefik-reboot", hosts: host_list
158
+ say "Downgraded to Traefik on #{host_list}", :magenta
159
+ end
160
+ end
161
+ end
122
162
  end
@@ -23,7 +23,7 @@ class Kamal::Commander::Specifics
23
23
  end
24
24
 
25
25
  def accessory_hosts
26
- specific_hosts || config.accessories.flat_map(&:hosts)
26
+ config.accessories.flat_map(&:hosts) & specified_hosts
27
27
  end
28
28
 
29
29
  private
@@ -56,6 +56,13 @@ class Kamal::Commander
56
56
  end
57
57
  end
58
58
 
59
+ def with_specific_hosts(hosts)
60
+ original_hosts, self.specific_hosts = specific_hosts, hosts
61
+ yield
62
+ ensure
63
+ self.specific_hosts = original_hosts
64
+ end
65
+
59
66
  def accessory_names
60
67
  config.accessories&.collect(&:name) || []
61
68
  end
@@ -62,6 +62,15 @@ class Kamal::Commands::Traefik < Kamal::Commands::Base
62
62
  [ :rm, "-f", env.secrets_file ]
63
63
  end
64
64
 
65
+ def cleanup_kamal_proxy
66
+ chain \
67
+ docker(:container, :stop, "kamal-proxy"),
68
+ combine(
69
+ docker(:container, :prune, "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"),
70
+ docker(:image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy")
71
+ )
72
+ end
73
+
65
74
  private
66
75
  def publish_args
67
76
  argumentize "--publish", port if publish?
@@ -17,8 +17,8 @@ traefik:
17
17
 
18
18
  # Image
19
19
  #
20
- # The Traefik image to use, defaults to `traefik:v2.10`
21
- image: traefik:v2.9
20
+ # The Traefik image to use, defaults to `traefik:v2.11`
21
+ image: traefik:v2.11
22
22
 
23
23
  # Host port
24
24
  #
@@ -1,5 +1,5 @@
1
1
  class Kamal::Configuration::Traefik
2
- DEFAULT_IMAGE = "traefik:v2.10"
2
+ DEFAULT_IMAGE = "traefik:v2.11"
3
3
  CONTAINER_PORT = 80
4
4
  DEFAULT_ARGS = {
5
5
  "log.level" => "DEBUG"
data/lib/kamal/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kamal
2
- VERSION = "1.8.3"
2
+ VERSION = "1.9.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -327,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
327
  - !ruby/object:Gem::Version
328
328
  version: '0'
329
329
  requirements: []
330
- rubygems_version: 3.5.11
330
+ rubygems_version: 3.3.22
331
331
  signing_key:
332
332
  specification_version: 4
333
333
  summary: Deploy web apps in containers to servers running Docker with zero downtime.