Class: Dash::Cli::Proxy::LegacyRename

Inherits:
Object
  • Object
show all
Defined in:
lib/dash/cli/proxy/legacy_rename.rb

Overview

Stage 3c migration: brings a host that still carries pre-rename container identity onto the renamed one.

Three steps, run in this order on each proxy host before the normal boot:

1. Bridge the network. Docker cannot rename one, so `dash` is created
 alongside `kamal` and everything still attached to the old network joins
 the new one. App containers would be replaced by the next deploy anyway;
 accessories are not, which is the whole reason this exists — without it a
 renamed proxy cannot reach `db` or `redis`.

2. Copy the config volume. It holds the routing table and the ACME account
 and certificate cache, so losing it means re-issuing every certificate
 and spending Let's Encrypt rate limits to get back to where we were. This
 must happen before the new container starts.

3. Replace the legacy container. A rename means the old container has to
 release ports 80/443 before the new one can claim them, and no
 port-holder handoff spans two container names — so this stage accepts a
 brief outage per host. Deliberate; see zoolutions/dash#124.

Every step is idempotent and guarded on its destination not already existing, so a second deploy is a no-op. Nothing here removes the legacy network or volume: an operator who wants them gone removes them by hand, and stage 3d deletes this class outright.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, sshkit) ⇒ LegacyRename

Returns a new instance of LegacyRename.



30
31
32
33
# File 'lib/dash/cli/proxy/legacy_rename.rb', line 30

def initialize(host, sshkit)
  @host = host
  @sshkit = sshkit
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



27
28
29
# File 'lib/dash/cli/proxy/legacy_rename.rb', line 27

def host
  @host
end

#sshkitObject (readonly)

Returns the value of attribute sshkit.



27
28
29
# File 'lib/dash/cli/proxy/legacy_rename.rb', line 27

def sshkit
  @sshkit
end

Instance Method Details

#runObject



35
36
37
38
39
# File 'lib/dash/cli/proxy/legacy_rename.rb', line 35

def run
  bridge_network
  adopt_config_volume
  replace_legacy_container
end