percheron 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c4858cd5f4ec9b26b7976179c56f074a1cb5570
4
- data.tar.gz: 050b74b700b9c127766e5454eba7aea97c85ba7c
3
+ metadata.gz: bea44fa6bffb36f64cc87ea1b7440f5adec930ee
4
+ data.tar.gz: f80411ab025ea216f43d8f114160e3d8007e03e8
5
5
  SHA512:
6
- metadata.gz: 9865aad4f0d56c8e2607bd74dc579443d7c645afc20c1362b855ad867c09475080d5588ffcdf89f86ed89e5cf7ab0e3791b2f85cc8e91565b54fda597198ecb0
7
- data.tar.gz: 438581d49d52687a2d06cf5d6bd538b3f1bf0df2dfe7b5dab655e1b2bd5a87f62fa5a194f559a3b41dfdf5bebeb32f54aadc24c0a4be3bdc5f6f510ee7bd31ef
6
+ metadata.gz: 820eebf1087b9201bd950c3eb989c993389974d0b46b574421516dcaf4cc7ab241b0b077b1894b45191b1be56a56d11faaa54ab055e2ef02601cc4f2a1a11bf9
7
+ data.tar.gz: 8428c2dc52c9cf6ff2ca82a3a508d9112955b9b5d6cbef68079ffdabd1650def1c6a0263b657fc0830f6e5a173671750813399a7ffd638a0c55458500cd93238
@@ -1,3 +1,9 @@
1
+ ## v0.8.1 / 2015-08-21
2
+
3
+ * BUGfix when creating units via Start action
4
+ * Support needed_unit_names and dependant_unit_names
5
+ * Added image size to the ascii table for status
6
+
1
7
  ## v0.8.0 / 2015-08-19
2
8
 
3
9
  * Hostname is the full `<stack_name>_<name>` by default
data/README.md CHANGED
@@ -81,13 +81,11 @@ Parameters:
81
81
 
82
82
  Subcommands:
83
83
  list, status List stacks and its units
84
- console Start a pry console session
85
84
  start Start a stack
86
85
  stop Stop a stack
87
86
  restart Restart a stack
88
- build Build images for a stack
89
- create Build images and create units for a stack
90
- recreate Recreate a stack
87
+ build, rebuild (Re)build image(s) for a stack
88
+ create, recreate (Re)build image(s) and (re)create units for a stack
91
89
  purge Purge a stack
92
90
  shell Shell into a unit
93
91
  logs Show logs for a unit
@@ -96,13 +94,15 @@ Subcommands:
96
94
  Options:
97
95
  -h, --help print help
98
96
  -c, --config_file CONFIG Config file (default: ".percheron.yml")
99
- --version show version
97
+ --version show versionn
100
98
  ```
101
99
 
102
100
  ## Demo (using boot2docker)
103
101
 
104
102
  1) Get boot2docker up and running
105
103
 
104
+ Follow the directions at https://docs.docker.com/installation
105
+
106
106
  ```bash
107
107
  boot2docker up && eval $(boot2docker shellinit) && export BOOT2DOCKER_IP=$(boot2docker ip)
108
108
  ```
@@ -126,14 +126,14 @@ stacks:
126
126
  docker_image: gliderlabs/consul-server:0.5
127
127
  start_args: [ "-bootstrap", "-client", "0.0.0.0", "-data-dir", "/data", "-ui-dir", "/ui" ]
128
128
  ports:
129
- - 8500:8500
130
- - 8600:53/udp
129
+ - "8500:8500"
130
+ - "8600:53/udp"
131
131
  - name: agent
132
132
  version: 1.0.0
133
133
  instances: 2
134
134
  docker_image: gliderlabs/consul-agent:0.5
135
135
  start_args: [ "-join", "master" ]
136
- dependent_unit_names:
136
+ needed_unit_names:
137
137
  - master
138
138
  ```
139
139
 
@@ -169,7 +169,7 @@ percheron status consul-stack
169
169
  6) Ensure consul is running
170
170
 
171
171
  ```bash
172
- curl http://boot2docker:8500/v1/catalog/nodes
172
+ curl http://${BOOT2DOCKER_IP}:8500/v1/catalog/nodes
173
173
 
174
174
  [{"Node":"agent1","Address":"172.17.0.5"},{"Node":"agent2","Address":"172.17.0.6"},{"Node":"master","Address":"172.17.0.4"}]
175
175
  ```
@@ -177,7 +177,7 @@ curl http://boot2docker:8500/v1/catalog/nodes
177
177
  7) Perform some DNS lookups using consul
178
178
 
179
179
  ```bash
180
- dig @boot2docker -p 8600 master.node.consul agent1.node.consul agent2.node.consul +short
180
+ dig @${BOOT2DOCKER_IP} -p 8600 master.node.consul agent1.node.consul agent2.node.consul +short
181
181
 
182
182
  172.17.0.7
183
183
  172.17.0.8
@@ -187,7 +187,7 @@ dig @boot2docker -p 8600 master.node.consul agent1.node.consul agent2.node.consu
187
187
  8) Bring up the consul UI
188
188
 
189
189
  ```bash
190
- open http://boot2docker:8500/ui
190
+ open http://${BOOT2DOCKER_IP}:8500/ui
191
191
  ```
192
192
 
193
193
  9) Purge it!
@@ -213,10 +213,6 @@ percheron graph consul-stack
213
213
 
214
214
  ![consul-stack](https://raw.githubusercontent.com/ashmckenzie/percheron-consul/master/assets/stack.png)
215
215
 
216
- ## Demo asciicast
217
-
218
- [![asciicast](https://asciinema.org/a/7l1ar35xlmfsaphhptrqvx7jg.png)](https://asciinema.org/a/7l1ar35xlmfsaphhptrqvx7jg)
219
-
220
216
  ## Debugging
221
217
 
222
218
  To perform debugging you will need to install the `pry-byebug` gem:
@@ -8,12 +8,12 @@ stacks:
8
8
  docker_image: gliderlabs/consul-server:0.5
9
9
  start_args: [ "-bootstrap", "-client", "0.0.0.0", "-data-dir", "/data", "-ui-dir", "/ui" ]
10
10
  ports:
11
- - 8500:8500
12
- - 8600:53/udp
11
+ - "8500:8500"
12
+ - "8600:53/udp"
13
13
  - name: agent
14
14
  version: 1.0.0
15
15
  instances: 2
16
16
  docker_image: gliderlabs/consul-agent:0.5
17
17
  start_args: [ "-join", "master" ]
18
- dependent_unit_names:
18
+ needed_unit_names:
19
19
  - master
@@ -112,8 +112,8 @@ module Percheron
112
112
  end
113
113
 
114
114
  def start_and_insert_scripts!
115
- Start.new(unit).execute!
116
115
  insert_post_start_scripts!
116
+ Start.new(unit, create: false).execute!
117
117
  end
118
118
 
119
119
  def update_dockerfile_md5!
@@ -3,17 +3,18 @@ module Percheron
3
3
  class Start
4
4
  include Base
5
5
 
6
- def initialize(unit, needed_units: [], cmd: false, exec_scripts: true)
6
+ def initialize(unit, needed_units: [], create: true, cmd: false, exec_scripts: true)
7
7
  @unit = unit
8
8
  @needed_units = needed_units
9
+ @create = create
9
10
  @cmd = cmd
10
11
  @exec_scripts = exec_scripts
11
12
  end
12
13
 
13
14
  def execute!
14
- results = []
15
- results << create!
16
- unless unit.running?
15
+ return nil if unit.running?
16
+ results = [ create! ]
17
+ if unit.startable?
17
18
  results << start!
18
19
  results << execute_post_start_scripts!
19
20
  end
@@ -22,21 +23,40 @@ module Percheron
22
23
 
23
24
  private
24
25
 
25
- attr_reader :unit, :needed_units, :cmd, :exec_scripts
26
+ attr_reader :unit, :needed_units, :create, :cmd, :exec_scripts
27
+ alias_method :create?, :create
26
28
 
27
29
  def exec_scripts?
28
30
  !unit.post_start_scripts.empty? && exec_scripts
29
31
  end
30
32
 
31
33
  def create!
32
- return nil if unit.exists?
34
+ return nil unless create?
33
35
  Create.new(unit, cmd: cmd).execute!
34
36
  end
35
37
 
36
38
  def start!
37
- return nil if !unit.startable? || unit.running?
38
- $logger.info "Starting '#{unit.display_name}' unit"
39
- unit.container.start!
39
+ return nil if unit_running?
40
+ if needed_unit_names_not_running.empty?
41
+ $logger.info "Starting '#{unit.display_name}' unit"
42
+ unit.container.start!
43
+ else
44
+ $logger.error "Cannot start '%s' unit, %s not running" %
45
+ [ unit.display_name, needed_unit_names_not_running ]
46
+ end
47
+ end
48
+
49
+ def unit_running?
50
+ !unit.startable? || unit.running?
51
+ end
52
+
53
+ def needed_unit_names_not_running
54
+ @needed_unit_names_not_running ||= begin
55
+ unit.startable_needed_units.each_with_object([]) do |unit_tuple, all|
56
+ _, unit = unit_tuple
57
+ all << unit.name unless unit.running?
58
+ end
59
+ end
40
60
  end
41
61
 
42
62
  def execute_post_start_scripts!
@@ -14,7 +14,7 @@ module Percheron
14
14
  private
15
15
 
16
16
  def confirm?
17
- ask('Are you sure? (y|n) ') do |q|
17
+ ask('Are you sure you want to purge? (y|n) ') do |q|
18
18
  q.validate = /y(es)?|n(o)?/i
19
19
  end.match(/y(es)?/i)
20
20
  end
@@ -30,6 +30,7 @@ module Percheron
30
30
  'IP',
31
31
  'Ports',
32
32
  'Volumes',
33
+ 'Size',
33
34
  'Version'
34
35
  ]
35
36
  end
@@ -59,6 +60,7 @@ module Percheron
59
60
  unit.ip,
60
61
  unit.ports.join(', '),
61
62
  unit.volumes.join("\n"),
63
+ unit.image_size,
62
64
  version(unit)
63
65
  ]
64
66
  end
@@ -8,8 +8,8 @@ module Percheron
8
8
  include Unit::ImageHelper
9
9
 
10
10
  def_delegators :unit_config, :name, :pseudo_name, :docker_image
11
- def_config_item_with_default :unit_config, [], :env, :ports, :volumes, :needed_unit_names,
12
- :pre_build_scripts, :post_start_scripts, :start_args, :dns
11
+ def_config_item_with_default :unit_config, [], :env, :ports, :volumes, :pre_build_scripts,
12
+ :post_start_scripts, :start_args, :dns
13
13
  def_config_item_with_default :unit_config, true, :startable
14
14
 
15
15
  def initialize(config, stack, unit_name)
@@ -20,6 +20,10 @@ module Percheron
20
20
  self
21
21
  end
22
22
 
23
+ def needed_unit_names
24
+ unit_config.fetch('needed_unit_names', unit_config.fetch('dependant_unit_names', []))
25
+ end
26
+
23
27
  def needed_units
24
28
  needed_unit_names.each_with_object({}) do |unit_name, all|
25
29
  all[unit_name] = stack.units[unit_name]
@@ -28,6 +28,10 @@ module Percheron
28
28
  def image_exists?
29
29
  image.nil? ? false : true
30
30
  end
31
+
32
+ def image_size
33
+ image.nil? ? nil : '%s MB' % [ image.info['VirtualSize'] / 1_048_576 ]
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module Percheron
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percheron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash McKenzie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp