Class: Dash::Cli::Proxy::Drift
- Inherits:
-
Object
- Object
- Dash::Cli::Proxy::Drift
- Defined in:
- lib/dash/cli/proxy/drift.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#sshkit ⇒ Object
readonly
Returns the value of attribute sshkit.
Instance Method Summary collapse
- #container_exists? ⇒ Boolean
-
#drifted? ⇒ Boolean
A proxy container has drifted when it was started with a different config digest than the one the current configuration produces.
- #expected_digest ⇒ Object
-
#initialize(host, sshkit) ⇒ Drift
constructor
A new instance of Drift.
-
#state ⇒ Object
One
docker inspectfor everything a boot asks about the running proxy: whether it exists, which image tag it runs, and the digest it was booted with. -
#version ⇒ Object
The tag the running proxy was booted from, for the minimum-version gate.
Constructor Details
#initialize(host, sshkit) ⇒ Drift
Returns a new instance of Drift.
5 6 7 8 |
# File 'lib/dash/cli/proxy/drift.rb', line 5 def initialize(host, sshkit) @host = host @sshkit = sshkit end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
2 3 4 |
# File 'lib/dash/cli/proxy/drift.rb', line 2 def host @host end |
#sshkit ⇒ Object (readonly)
Returns the value of attribute sshkit.
2 3 4 |
# File 'lib/dash/cli/proxy/drift.rb', line 2 def sshkit @sshkit end |
Instance Method Details
#container_exists? ⇒ Boolean
19 20 21 |
# File 'lib/dash/cli/proxy/drift.rb', line 19 def container_exists? state.exists? end |
#drifted? ⇒ Boolean
A proxy container has drifted when it was started with a different config digest than the one the current configuration produces. Containers booted by older dash versions carry no digest label and count as drifted, so they converge on the first deploy after upgrading.
33 34 35 36 |
# File 'lib/dash/cli/proxy/drift.rb', line 33 def drifted? return @drifted if defined?(@drifted) @drifted = container_exists? && current_digest != expected_digest end |
#expected_digest ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dash/cli/proxy/drift.rb', line 38 def expected_digest @expected_digest ||= if proxy.proxy_run_config proxy.proxy_run_config.config_digest else Dash::Configuration::Proxy::Run.digest(capture_with_info(*proxy.boot_config).strip) end end |
#state ⇒ Object
One docker inspect for everything a boot asks about the running proxy: whether it
exists, which image tag it runs, and the digest it was booted with. Captured once per
instance - dash proxy boot reads all three off it, and dash doctor only the first.
13 14 15 16 17 |
# File 'lib/dash/cli/proxy/drift.rb', line 13 def state @state ||= Dash::Commands::Proxy::State.parse( capture_with_info(*proxy.inspect_state, raise_on_non_zero_exit: false) ) end |
#version ⇒ Object
The tag the running proxy was booted from, for the minimum-version gate. Nil when nothing is running - a host with no proxy has no version to be too old.
25 26 27 |
# File 'lib/dash/cli/proxy/drift.rb', line 25 def version state.version end |