centurion 1.8.4 → 1.8.5
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 +4 -4
- data/.travis.yml +1 -0
- data/CONTRIBUTORS.md +3 -0
- data/README.md +8 -0
- data/lib/centurion/deploy.rb +14 -2
- data/lib/centurion/deploy_dsl.rb +4 -0
- data/lib/centurion/docker_server.rb +1 -1
- data/lib/centurion/docker_via_cli.rb +8 -0
- data/lib/centurion/service.rb +8 -0
- data/lib/centurion/version.rb +1 -1
- data/lib/tasks/deploy.rake +37 -2
- data/spec/deploy_dsl_spec.rb +10 -0
- data/spec/dogestry_spec.rb +0 -9
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54fb3e35e5c7be90b4d79745d899b8434157977f
|
|
4
|
+
data.tar.gz: 13355844e36026541dd2d31a4d9ed2ac3c099dd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de4a567728bf795ca5f9dff906b3a6ccf97607689a0bf1a1ccba31a30d0a8ecc3e825b2efa3118645087773896f0b9c592a2f8126e303e88c08082804482815d
|
|
7
|
+
data.tar.gz: 0c9c70fe003c2eac325bc9b130371425e1e67429a2a45a6a43aee78828dcb218fd3f5dde3a785714d47e3b706e34c69f884e6f492de208915b75a4e3f0a841d6
|
data/.travis.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
language: ruby
|
data/CONTRIBUTORS.md
CHANGED
|
@@ -13,6 +13,7 @@ Your name could be here!
|
|
|
13
13
|
* [Jon Wood][jellybob]
|
|
14
14
|
* [Mark Borcherding][markborcherding]
|
|
15
15
|
* [Nick Laferriere][laferrieren]
|
|
16
|
+
* [Hugo Chinchilla][hugochinchilla]
|
|
16
17
|
|
|
17
18
|
Pre-release
|
|
18
19
|
-----------
|
|
@@ -74,3 +75,5 @@ Contributor | Commits | Additions | Deletio
|
|
|
74
75
|
[skarap]: https://github.com/skarap
|
|
75
76
|
[jellybob]: https://github.com/jellybob
|
|
76
77
|
[markborcherding]: https://github.com/markborcherding
|
|
78
|
+
[dselans]: https://github.com/dselans
|
|
79
|
+
[idleyoungman]: https://github.com/idleyoungman
|
data/README.md
CHANGED
|
@@ -394,6 +394,14 @@ with `/bin/bash`. It will use the first host from the host list.
|
|
|
394
394
|
````bash
|
|
395
395
|
$ bundle exec centurion -p radio-radio -e staging -a deploy_console
|
|
396
396
|
````
|
|
397
|
+
### Repair unhealthy docker containers
|
|
398
|
+
|
|
399
|
+
This will preform a health check on each host using rolling deployment
|
|
400
|
+
health check settings and redeploy to the host if a health check fails.
|
|
401
|
+
|
|
402
|
+
````bash
|
|
403
|
+
$ bundle exec centurion -p radio-radio -e staging -a repair
|
|
404
|
+
````
|
|
397
405
|
|
|
398
406
|
###List all the tags running on your servers for a particular project
|
|
399
407
|
|
data/lib/centurion/deploy.rb
CHANGED
|
@@ -23,9 +23,11 @@ module Centurion::Deploy
|
|
|
23
23
|
|
|
24
24
|
def wait_for_health_check_ok(health_check_method, target_server, container_id, port, endpoint, image_id, tag, sleep_time=5, retries=12)
|
|
25
25
|
info 'Waiting for the port to come up'
|
|
26
|
+
healthy = false
|
|
26
27
|
1.upto(retries) do
|
|
27
28
|
if container_up?(target_server, container_id) && health_check_method.call(target_server, port, endpoint)
|
|
28
29
|
info 'Container is up!'
|
|
30
|
+
healthy = true
|
|
29
31
|
break
|
|
30
32
|
end
|
|
31
33
|
|
|
@@ -33,7 +35,7 @@ module Centurion::Deploy
|
|
|
33
35
|
sleep(sleep_time)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
unless
|
|
38
|
+
unless healthy
|
|
37
39
|
error "Failed to validate started container on #{target_server.hostname}:#{port}"
|
|
38
40
|
exit(FAILED_CONTAINER_VALIDATION)
|
|
39
41
|
end
|
|
@@ -97,7 +99,7 @@ module Centurion::Deploy
|
|
|
97
99
|
|
|
98
100
|
def start_new_container(server, service, restart_policy)
|
|
99
101
|
container_config = service.build_config(server.hostname, &hostname_proc)
|
|
100
|
-
info "Creating new container for #{container_config['Image']
|
|
102
|
+
info "Creating new container for #{container_config['Image']}"
|
|
101
103
|
container = server.create_container(container_config, service.name)
|
|
102
104
|
|
|
103
105
|
host_config = service.build_host_config(restart_policy)
|
|
@@ -126,4 +128,14 @@ module Centurion::Deploy
|
|
|
126
128
|
|
|
127
129
|
server.attach(container['Id'])
|
|
128
130
|
end
|
|
131
|
+
|
|
132
|
+
def enter_container(server, service)
|
|
133
|
+
container = if service.public_ports.nil? || service.public_ports.empty?
|
|
134
|
+
server.find_containers_by_name(service.name).first
|
|
135
|
+
else
|
|
136
|
+
server.find_containers_by_public_port(service.public_ports.first).first
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
server.exec_it(container["Id"], "/bin/bash")
|
|
140
|
+
end
|
|
129
141
|
end
|
data/lib/centurion/deploy_dsl.rb
CHANGED
|
@@ -8,6 +8,10 @@ module Centurion::DeployDSL
|
|
|
8
8
|
build_server_group.tap { |hosts| hosts.each { |host| block.call(host) } }
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
def on_first_docker_host(&block)
|
|
12
|
+
build_server_group.tap { |hosts| block.call(hosts.first) }
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
def env_vars(new_vars)
|
|
12
16
|
current = fetch(:env_vars, {})
|
|
13
17
|
new_vars.each_pair do |new_key, new_value|
|
|
@@ -16,7 +16,7 @@ class Centurion::DockerServer
|
|
|
16
16
|
def_delegators :docker_via_api, :create_container, :inspect_container,
|
|
17
17
|
:inspect_image, :ps, :start_container, :stop_container,
|
|
18
18
|
:remove_container, :restart_container
|
|
19
|
-
def_delegators :docker_via_cli, :pull, :tail, :attach, :exec
|
|
19
|
+
def_delegators :docker_via_cli, :pull, :tail, :attach, :exec, :exec_it
|
|
20
20
|
|
|
21
21
|
def initialize(host, docker_path, tls_params = {})
|
|
22
22
|
@docker_path = docker_path
|
|
@@ -31,6 +31,14 @@ class Centurion::DockerViaCli
|
|
|
31
31
|
Centurion::Shell.echo(build_command(:exec, "#{container_id} #{commandline}"))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def exec_it(container_id, commandline)
|
|
35
|
+
# the "or true" on the command is to prevent an exception from Shell.validate_status
|
|
36
|
+
# because docker exec returns the same exit code as the latest command executed on
|
|
37
|
+
# the shell, which causes an exception to be raised if the latest comand executed
|
|
38
|
+
# was unsuccessful when you exit the shell.
|
|
39
|
+
Centurion::Shell.echo(build_command(:exec, "-it #{container_id} #{commandline} || true"))
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
private
|
|
35
43
|
|
|
36
44
|
def self.tls_keys
|
data/lib/centurion/service.rb
CHANGED
|
@@ -34,6 +34,8 @@ module Centurion
|
|
|
34
34
|
s.port_bindings = fetch(:port_bindings, [])
|
|
35
35
|
s.network_mode = fetch(:network_mode, 'bridge')
|
|
36
36
|
s.command = fetch(:command, nil)
|
|
37
|
+
s.memory = fetch(:memory, 0)
|
|
38
|
+
s.cpu_shares = fetch(:cpu_shares, 0)
|
|
37
39
|
|
|
38
40
|
s.add_env_vars(fetch(:env_vars, {}))
|
|
39
41
|
end
|
|
@@ -141,6 +143,12 @@ module Centurion
|
|
|
141
143
|
# Add ExtraHosts if needed
|
|
142
144
|
host_config['ExtraHosts'] = extra_hosts if extra_hosts
|
|
143
145
|
|
|
146
|
+
# Set memory limits
|
|
147
|
+
host_config['Memory'] = memory if memory
|
|
148
|
+
|
|
149
|
+
# Set cpushare limits
|
|
150
|
+
host_config['CpuShares'] = cpu_shares if cpu_shares
|
|
151
|
+
|
|
144
152
|
# Restart Policy
|
|
145
153
|
if restart_policy
|
|
146
154
|
host_config['RestartPolicy'] = {}
|
data/lib/centurion/version.rb
CHANGED
data/lib/tasks/deploy.rake
CHANGED
|
@@ -12,7 +12,7 @@ end
|
|
|
12
12
|
|
|
13
13
|
task :deploy_console do
|
|
14
14
|
invoke 'deploy:get_image'
|
|
15
|
-
invoke 'deploy:stop'
|
|
15
|
+
#invoke 'deploy:stop'
|
|
16
16
|
invoke 'deploy:launch_console'
|
|
17
17
|
invoke 'deploy:cleanup'
|
|
18
18
|
end
|
|
@@ -23,7 +23,14 @@ task :rolling_deploy do
|
|
|
23
23
|
invoke 'deploy:cleanup'
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
task :repair do
|
|
27
|
+
invoke 'deploy:get_image'
|
|
28
|
+
invoke 'deploy:repair'
|
|
29
|
+
invoke 'deploy:cleanup'
|
|
30
|
+
end
|
|
31
|
+
|
|
26
32
|
task :stop => ['deploy:stop']
|
|
33
|
+
task :enter_container => ['deploy:enter_container']
|
|
27
34
|
|
|
28
35
|
namespace :dev do
|
|
29
36
|
task :export_only do
|
|
@@ -106,11 +113,18 @@ namespace :deploy do
|
|
|
106
113
|
end
|
|
107
114
|
|
|
108
115
|
task :launch_console do
|
|
109
|
-
|
|
116
|
+
on_first_docker_host do |server|
|
|
117
|
+
defined_service.port_bindings.clear
|
|
110
118
|
launch_console(server, defined_service)
|
|
111
119
|
end
|
|
112
120
|
end
|
|
113
121
|
|
|
122
|
+
task :enter_container do
|
|
123
|
+
on_first_docker_host do |server|
|
|
124
|
+
enter_container(server, defined_service)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
114
128
|
task :rolling_deploy do
|
|
115
129
|
on_each_docker_host do |server|
|
|
116
130
|
service = defined_service
|
|
@@ -138,6 +152,27 @@ namespace :deploy do
|
|
|
138
152
|
end
|
|
139
153
|
end
|
|
140
154
|
|
|
155
|
+
task :repair do
|
|
156
|
+
service = defined_service
|
|
157
|
+
|
|
158
|
+
# find nodes that are down
|
|
159
|
+
on_each_docker_host do |server|
|
|
160
|
+
failed_healthcheck = false
|
|
161
|
+
public_ports = service.public_ports - fetch(:rolling_deploy_skip_ports, [])
|
|
162
|
+
public_ports.each do |port|
|
|
163
|
+
unless method(:http_status_ok?).call(server, port, fetch(:status_endpoint, '/'))
|
|
164
|
+
failed_healthcheck = true
|
|
165
|
+
break
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
next unless failed_healthcheck
|
|
169
|
+
# issue stop to clean host
|
|
170
|
+
stop_containers(server, service, fetch(:stop_timeout, 30))
|
|
171
|
+
# start new container services is already down, so no need to role gracefully
|
|
172
|
+
start_new_container(server, defined_service, defined_restart_policy)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
141
176
|
task :cleanup do
|
|
142
177
|
on_each_docker_host do |server|
|
|
143
178
|
cleanup_containers(server, defined_service)
|
data/spec/deploy_dsl_spec.rb
CHANGED
|
@@ -124,6 +124,16 @@ describe Centurion::DeployDSL do
|
|
|
124
124
|
expect(DeployDSLTest.defined_service.network_mode).to eq('host')
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
+
it 'accepts cpu share limit' do
|
|
128
|
+
DeployDSLTest.cpu_shares(12345678)
|
|
129
|
+
expect(DeployDSLTest.defined_service.cpu_shares).to eq(12345678)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'accepts memory limit' do
|
|
133
|
+
DeployDSLTest.memory(12345)
|
|
134
|
+
expect(DeployDSLTest.defined_service.memory).to eq(12345)
|
|
135
|
+
end
|
|
136
|
+
|
|
127
137
|
it 'accepts bridge mode' do
|
|
128
138
|
DeployDSLTest.network_mode('bridge')
|
|
129
139
|
expect(DeployDSLTest.defined_service.network_mode).to eq('bridge')
|
data/spec/dogestry_spec.rb
CHANGED
|
@@ -55,15 +55,6 @@ describe Centurion::Dogestry do
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
describe '#pull' do
|
|
59
|
-
it 'returns correct value' do
|
|
60
|
-
if registry.which('dogestry')
|
|
61
|
-
expect(registry).to receive(:echo).with("dogestry #{flags} pull #{registry.s3_url} #{repo}")
|
|
62
|
-
registry.pull(repo, pull_hosts)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
58
|
describe '#which' do
|
|
68
59
|
it 'finds dogestry command line' do
|
|
69
60
|
allow(File).to receive(:executable?).and_return(true)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: centurion
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nic Benders
|
|
@@ -20,7 +20,7 @@ authors:
|
|
|
20
20
|
autorequire:
|
|
21
21
|
bindir: bin
|
|
22
22
|
cert_chain: []
|
|
23
|
-
date:
|
|
23
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
|
24
24
|
dependencies:
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: trollop
|
|
@@ -156,6 +156,7 @@ extensions: []
|
|
|
156
156
|
extra_rdoc_files: []
|
|
157
157
|
files:
|
|
158
158
|
- ".gitignore"
|
|
159
|
+
- ".travis.yml"
|
|
159
160
|
- CONTRIBUTORS.md
|
|
160
161
|
- Gemfile
|
|
161
162
|
- LICENSE
|