rollo 0.3.0 → 0.8.0.pre.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.
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.3.7
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.3
5
- before_install: gem install bundler -v 1.16.2
data/exe/rollo DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'thor'
3
- require 'rollo'
4
-
5
- Rollo::Commands::Main.start
data/go DELETED
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- [ -n "$GO_DEBUG" ] && set -x
4
- set -e
5
-
6
- project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7
-
8
- verbose="no"
9
- skip_checks="no"
10
- offline="no"
11
-
12
- missing_dependency="no"
13
-
14
- [ -n "$GO_DEBUG" ] && verbose="yes"
15
- [ -n "$GO_SKIP_CHECKS" ] && skip_checks="yes"
16
- [ -n "$GO_OFFLINE" ] && offline="yes"
17
-
18
-
19
- if [[ "$skip_checks" = "no" ]]; then
20
- echo "Checking for system dependencies."
21
- ruby_version="$(cat "$project_dir"/.ruby-version)"
22
- if ! type ruby >/dev/null 2>&1 || ! ruby -v | grep -q "$ruby_version"; then
23
- echo "This codebase requires Ruby $ruby_version."
24
- missing_dependency="yes"
25
- fi
26
-
27
- if ! type bundler >/dev/null 2>&1; then
28
- echo "This codebase requires Bundler."
29
- missing_dependency="yes"
30
- fi
31
-
32
- if [[ "$missing_dependency" = "yes" ]]; then
33
- echo "Please install missing dependencies to continue."
34
- exit 1
35
- fi
36
-
37
- echo "All system dependencies present. Continuing."
38
- fi
39
-
40
- if [[ "$offline" = "no" ]]; then
41
- echo "Installing bundler."
42
- if [[ "$verbose" = "yes" ]]; then
43
- gem install --no-document bundler
44
- else
45
- gem install --no-document bundler > /dev/null
46
- fi
47
-
48
- echo "Installing ruby dependencies."
49
- if [[ "$verbose" = "yes" ]]; then
50
- bundle install
51
- else
52
- bundle install > /dev/null
53
- fi
54
- fi
55
-
56
- echo "Starting rake."
57
- if [[ "$verbose" = "yes" ]]; then
58
- time bundle exec rake --verbose "$@"
59
- else
60
- time bundle exec rake "$@"
61
- fi
@@ -1,184 +0,0 @@
1
- require 'thor'
2
- require_relative '../model'
3
-
4
- module Rollo
5
- module Commands
6
- class HostCluster < Thor
7
- def self.exit_on_failure?
8
- true
9
- end
10
-
11
- desc(
12
- 'expand REGION ASG_NAME ECS_CLUSTER_NAME',
13
- '')
14
- method_option(
15
- :batch_size,
16
- aliases: '-b',
17
- type: :numeric,
18
- default: 3,
19
- desc: 'The number of hosts to add at a time.')
20
- def expand(
21
- region, asg_name, _,
22
- host_cluster = nil)
23
- batch_size = options[:batch_size]
24
-
25
- host_cluster = host_cluster ||
26
- Rollo::Model::HostCluster.new(asg_name, region)
27
-
28
- say("Increasing host cluster desired capacity by #{batch_size}...")
29
- with_padding do
30
- host_cluster.increase_capacity_by(batch_size) do |on|
31
- on.prepare do |current, target|
32
- say(
33
- "Changing desired capacity from #{current} to " +
34
- "#{target}...")
35
- end
36
- on.waiting_for_start do |attempt|
37
- say(
38
- 'Waiting for capacity change to start ' +
39
- "(attempt #{attempt})...")
40
- end
41
- on.waiting_for_end do |attempt|
42
- say(
43
- 'Waiting for capacity change to complete ' +
44
- "(attempt #{attempt})...")
45
- end
46
- on.waiting_for_health do |attempt|
47
- say("Waiting for a healthy state (attempt #{attempt})")
48
- end
49
- end
50
- end
51
- say "Host cluster desired capacity increased, continuing..."
52
- end
53
-
54
- desc(
55
- 'contract REGION ASG_NAME ECS_CLUSTER_NAME',
56
- '')
57
- method_option(
58
- :batch_size,
59
- aliases: '-b',
60
- type: :numeric,
61
- default: 3,
62
- desc: 'The number of hosts to remove at a time.')
63
- def contract(
64
- region, asg_name, ecs_cluster_name,
65
- host_cluster = nil, service_cluster = nil)
66
- batch_size = options[:batch_size]
67
-
68
- host_cluster = host_cluster ||
69
- Rollo::Model::HostCluster.new(asg_name, region)
70
- service_cluster = service_cluster ||
71
- Rollo::Model::ServiceCluster.new(ecs_cluster_name, region)
72
-
73
- say("Decreasing host cluster desired capacity by #{batch_size}...")
74
- with_padding do
75
- host_cluster.decrease_capacity_by(batch_size) do |on|
76
- on.prepare do |current, target|
77
- say(
78
- "Changing desired capacity from #{current} to " +
79
- "#{target}...")
80
- end
81
- on.waiting_for_start do |attempt|
82
- say(
83
- "Waiting for capacity change to start " +
84
- "(attempt #{attempt})...")
85
- end
86
- on.waiting_for_end do |attempt|
87
- say(
88
- "Waiting for capacity change to complete " +
89
- "(attempt #{attempt})...")
90
- end
91
- on.waiting_for_health do |attempt|
92
- say(
93
- "Waiting for host cluster to reach healthy state " +
94
- "(attempt #{attempt})...")
95
- end
96
- end
97
- service_cluster.with_replica_services do |on|
98
- on.each_service do |service|
99
- service.wait_for_service_health do |on|
100
- on.waiting_for_health do |attempt|
101
- say(
102
- "Waiting for service #{service.name} to reach a " +
103
- "steady state (attempt #{attempt})...")
104
- end
105
- end
106
- end
107
- end
108
- end
109
- say "Host cluster desired capacity decreased, continuing..."
110
- end
111
-
112
- desc(
113
- 'terminate REGION ASG_NAME ECS_CLUSTER_NAME INSTANCE_IDS*',
114
- '')
115
- method_option(
116
- :batch_size,
117
- aliases: '-b',
118
- type: :numeric,
119
- default: 3,
120
- desc: 'The number of hosts to add at a time.')
121
- method_option(
122
- :startup_time,
123
- aliases: '-t',
124
- type: :numeric,
125
- default: 2,
126
- desc: 'The number of minutes to wait for services to start up.')
127
- def terminate(
128
- region, asg_name, ecs_cluster_name, instance_ids,
129
- host_cluster = nil, service_cluster = nil)
130
- batch_size = options[:batch_size]
131
-
132
- service_start_wait_minutes = options[:startup_time]
133
- service_start_wait_seconds = 60 * service_start_wait_minutes
134
-
135
- host_cluster = host_cluster ||
136
- Rollo::Model::HostCluster.new(asg_name, region)
137
- service_cluster = service_cluster ||
138
- Rollo::Model::ServiceCluster.new(ecs_cluster_name, region)
139
-
140
- hosts = host_cluster.hosts.select {|h| instance_ids.include?(h.id) }
141
- host_batches = hosts.each_slice(batch_size).to_a
142
-
143
- say(
144
- 'Terminating old hosts in host cluster in batches of ' +
145
- "#{batch_size}...")
146
- with_padding do
147
- host_batches.each_with_index do |host_batch, index|
148
- say(
149
- "Batch #{index + 1} contains hosts: " +
150
- "\n\t\t[#{host_batch.map(&:id).join(",\n\t\t ")}]\n" +
151
- 'Terminating...')
152
- host_batch.each(&:terminate)
153
- host_cluster.wait_for_capacity_health do |on|
154
- on.waiting_for_health do |attempt|
155
- say(
156
- 'Waiting for host cluster to reach healthy state ' +
157
- "(attempt #{attempt})")
158
- end
159
- end
160
- service_cluster.with_replica_services do |on|
161
- on.each_service do |service|
162
- service.wait_for_service_health do |on|
163
- on.waiting_for_health do |attempt|
164
- say(
165
- "Waiting for service #{service.name} to reach a " +
166
- "steady state (attempt #{attempt})...")
167
- end
168
- end
169
- end
170
- end
171
- say(
172
- "Waiting #{service_start_wait_minutes} minute(s) for " +
173
- 'services to finish starting...')
174
- sleep(service_start_wait_seconds)
175
- say(
176
- "Waited #{service_start_wait_minutes} minute(s). " +
177
- 'Continuing...')
178
- end
179
- end
180
-
181
- end
182
- end
183
- end
184
- end
@@ -1,124 +0,0 @@
1
- require 'thor'
2
- require_relative '../model'
3
-
4
- module Rollo
5
- module Commands
6
- class ServiceCluster < Thor
7
- def self.exit_on_failure?
8
- true
9
- end
10
-
11
- desc(
12
- 'expand REGION ASG_NAME ECS_CLUSTER_NAME',
13
- '')
14
- method_option(
15
- :batch_size,
16
- aliases: '-b',
17
- type: :numeric,
18
- default: 3,
19
- desc: 'The number of service instances to add at a time.')
20
- method_option(
21
- :startup_time,
22
- aliases: '-t',
23
- type: :numeric,
24
- default: 2,
25
- desc: 'The number of minutes to wait for services to start up.')
26
-
27
- def expand(
28
- region, _, ecs_cluster_name,
29
- service_cluster = nil)
30
- batch_size = options[:batch_size]
31
- service_start_wait_minutes = options[:startup_time]
32
- service_start_wait_seconds = 60 * service_start_wait_minutes
33
-
34
- service_cluster = service_cluster ||
35
- Rollo::Model::ServiceCluster.new(ecs_cluster_name, region)
36
-
37
- say("Increasing service instance counts by #{batch_size}...")
38
- with_padding do
39
- service_cluster.with_replica_services do |on|
40
- on.start do |services|
41
- say(
42
- 'Service cluster contains services:' +
43
- "\n\t\t[#{services.map(&:name).join(",\n\t\t ")}]")
44
- end
45
- on.each_service do |service|
46
- say(
47
- "Increasing instance count by #{batch_size} " +
48
- "for #{service.name}")
49
- with_padding do
50
- service.increase_instance_count_by(batch_size) do |on|
51
- on.prepare do |current, target|
52
- say(
53
- "Changing instance count from #{current} " +
54
- "to #{target}...")
55
- end
56
- on.waiting_for_health do |attempt|
57
- say(
58
- "Waiting for service to reach a steady state " +
59
- "(attempt #{attempt})...")
60
- end
61
- end
62
- end
63
- end
64
- end
65
- end
66
- say(
67
- "Waiting #{service_start_wait_minutes} minute(s) for " +
68
- 'services to finish starting...')
69
- with_padding do
70
- sleep(service_start_wait_seconds)
71
- say(
72
- "Waited #{service_start_wait_minutes} minute(s). " +
73
- 'Continuing...')
74
- end
75
- say('Service instance counts increased, continuing...')
76
- end
77
-
78
- desc(
79
- 'contract REGION ASG_NAME ECS_CLUSTER_NAME',
80
- '')
81
- method_option(
82
- :batch_size,
83
- aliases: '-b',
84
- type: :numeric,
85
- default: 3,
86
- desc: 'The number of service instances to remove at a time.')
87
-
88
- def contract(
89
- region, _, ecs_cluster_name,
90
- service_cluster = nil)
91
- batch_size = options[:batch_size]
92
-
93
- service_cluster = service_cluster ||
94
- Rollo::Model::ServiceCluster.new(ecs_cluster_name, region)
95
-
96
- say("Decreasing service instance counts by #{batch_size}...")
97
- with_padding do
98
- service_cluster.with_replica_services do |on|
99
- on.each_service do |service|
100
- say(
101
- "Decreasing instance count by #{batch_size} " +
102
- "for #{service.name}")
103
- with_padding do
104
- service.decrease_instance_count_by(batch_size) do |on|
105
- on.prepare do |current, target|
106
- say(
107
- "Changing instance count from #{current} " +
108
- "to #{target}...")
109
- end
110
- on.waiting_for_health do |attempt|
111
- say(
112
- 'Waiting for service to reach a steady state ' +
113
- "(attempt #{attempt})...")
114
- end
115
- end
116
- end
117
- end
118
- end
119
- end
120
- say("Service instance counts decreased, continuing...")
121
- end
122
- end
123
- end
124
- end
data/rollo.gemspec DELETED
@@ -1,37 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'rollo/version'
4
- require 'date'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'rollo'
8
- spec.version = Rollo::VERSION
9
- spec.authors = ['Toby Clemson']
10
- spec.email = ['tobyclemson@gmail.com']
11
-
12
- spec.date = Date.today.to_s
13
- spec.summary = 'Cluster / service roller for AWS ECS.'
14
- spec.description = 'Strategies for rolling ECS container instance clusters.'
15
- spec.homepage = 'https://github.com/infrablocks/rollo'
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
20
- end
21
- spec.bindir = 'exe'
22
- spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
23
- spec.require_paths = ['lib']
24
-
25
- spec.add_dependency 'aws-sdk', '~> 3.0'
26
- spec.add_dependency 'aws-sdk-ecs', '~> 1.22'
27
- spec.add_dependency 'wait', '~> 0.5'
28
- spec.add_dependency 'hollerback', '~> 0.1'
29
- spec.add_dependency 'thor', '~> 0.20'
30
-
31
- spec.add_development_dependency 'bundler', '~> 1.17'
32
- spec.add_development_dependency 'rake', '~> 12.3'
33
- spec.add_development_dependency 'rspec', '~> 3.8'
34
- spec.add_development_dependency 'aruba', '~> 0.14'
35
- spec.add_development_dependency 'gem-release', '~> 2.0'
36
- spec.add_development_dependency 'irbtools', '~> 2.2'
37
- end