ecs-easy-cluster 0.0.3 → 0.0.4
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/lib/ecs/easy/cluster/base.rb +0 -8
- data/lib/ecs/easy/cluster/mem_scale.rb +39 -14
- data/lib/ecs/easy/cluster/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a16a8b4f530e203e99ec31aa3c2b4f55e18cc42b
|
4
|
+
data.tar.gz: 6cc1b2c1c06e6a39912206544ca2dc95eb40e0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4d9383c09a413fa137e32a878dbff86a6352a3243da85d0d5bbeb24033633aaeb0478c38f507d728ee1f2a85baa307192d72d239263e9f7b70dff300fda378
|
7
|
+
data.tar.gz: a2c89af6d47072ef66aa8d9742a7bf9727d45cb5187bfa63a104572015ab1839c4280f4044121eb8b3d52726f0b60d8df8678e966bd68f7f16df07dbd9c65d89
|
@@ -156,13 +156,5 @@ module Ecs::Easy::Cluster
|
|
156
156
|
puts e
|
157
157
|
end
|
158
158
|
|
159
|
-
private
|
160
|
-
def fail_reason( failures )
|
161
|
-
reasons = failures.map {|f| f.reason }
|
162
|
-
if reasons.include?( "RESOURCE:MEMORY" )
|
163
|
-
return "RESOURCE:MEMORY"
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
159
|
end
|
168
160
|
end
|
@@ -1,6 +1,27 @@
|
|
1
1
|
module Ecs::Easy::Cluster
|
2
2
|
class MemScale < Base
|
3
3
|
|
4
|
+
class CannotStartTaskError < StandardError
|
5
|
+
attr_reader :result
|
6
|
+
def initialize( result )
|
7
|
+
@result = result
|
8
|
+
end
|
9
|
+
|
10
|
+
def failures
|
11
|
+
return nil unless result
|
12
|
+
result.failures
|
13
|
+
end
|
14
|
+
|
15
|
+
def fail_reason
|
16
|
+
return nil if failures.empty?
|
17
|
+
reasons = failures.map {|f| f.reason }
|
18
|
+
if reasons.include?( "RESOURCE:MEMORY" )
|
19
|
+
return "RESOURCE:MEMORY"
|
20
|
+
end
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
4
25
|
EC2_PROFILE_PATH = File.expand_path("../config/ec2_profile.json", __FILE__)
|
5
26
|
INSTANCE_TYPES = JSON.parse(File.read( EC2_PROFILE_PATH ))
|
6
27
|
|
@@ -11,33 +32,37 @@ module Ecs::Easy::Cluster
|
|
11
32
|
end
|
12
33
|
end
|
13
34
|
|
14
|
-
|
15
|
-
|
35
|
+
retry_count = 3
|
36
|
+
begin
|
16
37
|
wait_until_ready
|
17
38
|
res = run_task!( task_definition, overrides )
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
unless res.failures.empty?
|
25
|
-
puts res.failures
|
26
|
-
case fail_reason(res.failures)
|
39
|
+
unless res.failures.empty?
|
40
|
+
raise CannotStartTaskError.new( res )
|
41
|
+
end
|
42
|
+
rescue CannotStartTaskError => e
|
43
|
+
puts e.failures
|
44
|
+
case e.fail_reason
|
27
45
|
when "RESOURCE:MEMORY"
|
28
46
|
puts "No enough memory on current container instances to execute this task. Add another container instance automatically."
|
29
47
|
|
30
48
|
if num_instances >= max_instances
|
31
|
-
|
49
|
+
puts "Couldn\'t scale more instances because it reaches maximum instances. You should upgrade the maximum number of instance to execute multiple tasks at the same time."
|
32
50
|
end
|
33
51
|
unless acceptable_task?( task_definition )
|
34
|
-
raise "
|
52
|
+
raise "Couldn\'t accept this task because of the lack of memory. You should upgrade ec2 instance type."
|
35
53
|
end
|
36
54
|
|
37
55
|
scale!
|
38
56
|
else
|
39
|
-
raise "Unknown reason: #{
|
57
|
+
raise "Unknown reason: #{e.failures}"
|
40
58
|
end
|
59
|
+
|
60
|
+
puts "Failed to run the task. Try again."
|
61
|
+
sleep 10
|
62
|
+
retry_count -= 1
|
63
|
+
retry if retry_count > 0
|
64
|
+
rescue => e
|
65
|
+
raise "Unknown reason: #{e}"
|
41
66
|
end
|
42
67
|
|
43
68
|
res
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecs-easy-cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- metheglin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|