ecs_compose 0.1.0.pre12 → 0.1.0.pre13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9631893f24b9aefdc6fba876721e9cdfb52b2635
4
- data.tar.gz: 5aea13e1e6d140ead8708fa72d3480fa630e4020
3
+ metadata.gz: a2272a942dcbab9f8fcac63a3dbc542c68fd86ac
4
+ data.tar.gz: 3f001cc3617347d0f5481a30dc75562763ae0990
5
5
  SHA512:
6
- metadata.gz: 3ddee4ff7648921d0015e29e4aa6190814da7a5119170821509ff42402f8c43b353d80aed6679012afc3151ebb05c1554d5aed3d8e7384289b2e75fc82e5b3ae
7
- data.tar.gz: d4638ac13bcf415d2cf4e19c7568e9d3636b335a2ee355a99a42be8e63243018d2d46ebf11e83dc416dbe667d2cdfe7dcf20ca99292dce9709a0d41e8ed8f412
6
+ metadata.gz: 7f4b853b2e3260adb594529a9bdd21c7999358beac5c0828ab1ecc09c70e8301bae844459ec9d24adf3764832895d55f95b0a9b0689eb45a07a6ad86e7f2406a
7
+ data.tar.gz: 68d28497bb0ee507e6749a22ccad039eb1e737c2d77e489ef798c710e516747676279d31b7e700bdfaa6678b24cbc8a0d2a9da12837b34fc855bc8fb8b40120d
@@ -0,0 +1,18 @@
1
+ module EcsCompose
2
+ # Common superclass of TaskError and ServiceError.
3
+ class DeploymentError < RuntimeError
4
+ #:nodoc:
5
+ def self.failure_error(failure)
6
+ "#{failure.fetch("reason")} (resource: #{failure.fetch("arn")})"
7
+ end
8
+
9
+ attr_reader :messages
10
+
11
+ # Create a new task error with one or more messages.
12
+ def initialize(messages)
13
+ message = (["ECS deployment errors occurred:"] + messages).join("\n- ")
14
+ super(message)
15
+ @messages = messages
16
+ end
17
+ end
18
+ end
@@ -76,6 +76,12 @@ module EcsCompose
76
76
  "--tasks", *arns)
77
77
  end
78
78
 
79
+ # Describe a set of services as JSON.
80
+ def self.describe_services(services)
81
+ run("describe-services",
82
+ "--services", *services)
83
+ end
84
+
79
85
  # Describe a set of tasks as JSON.
80
86
  def self.describe_tasks(arns)
81
87
  run("describe-tasks",
@@ -0,0 +1,30 @@
1
+ module EcsCompose
2
+ # We raise this error if `aws ecs describe-services` indicates that a
3
+ # service has failed to stablize.
4
+ class ServiceError < DeploymentError
5
+ # Raise an error if any of the described services failed to stabilize.
6
+ def self.fail_if_not_stabilized(service_descriptions)
7
+ failures = service_descriptions.fetch("failures")
8
+ services = service_descriptions.fetch("services")
9
+
10
+ errs1 = failures.map {|f| failure_error(f) }
11
+
12
+ errs2 = services.select do |s|
13
+ s.fetch("deployments").length != 1
14
+ end.map do |s|
15
+ "#{s.fetch("serviceName")}: multiple versions still deployed (see AWS console for details)"
16
+ end
17
+
18
+ errs3 = services.select do |s|
19
+ s.fetch("desiredCount") != s.fetch("runningCount")
20
+ end.map do |s|
21
+ "#{s.fetch("serviceName")}: #{s.fetch("desiredCount")} instances desired, #{s.fetch("runningCount")} running (see AWS console for details)"
22
+ end
23
+
24
+ errs = errs1 + errs2 + errs3
25
+ unless errs.empty?
26
+ raise new(errs)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -36,7 +36,11 @@ module EcsCompose
36
36
  # Wait for a set of services to reach a steady state.
37
37
  def self.wait_for_services(service_names)
38
38
  Ecs.wait_services_stable(service_names)
39
- # TODO: Check for errors during stabilization.
39
+ # TODO: We never actually get here if the services don't stabilize,
40
+ # because wait_services_stable will fail with `Waiter ServicesStable
41
+ # failed: Max attempts`. But we're keeping this code until we
42
+ # implement event polling and our own version of waiting.
43
+ ServiceError.fail_if_not_stabilized(Ecs.describe_services(service_names))
40
44
  end
41
45
 
42
46
  # Run this task definition as a one-shot ECS task, with the specified
@@ -1,7 +1,8 @@
1
1
  module EcsCompose
2
2
  # We raise this error if `aws ecs describe-tasks` indicates that a
3
3
  # process has failed.
4
- class TaskError < RuntimeError
4
+ class TaskError < DeploymentError
5
+ # Raise an error if any of the descriped tasks failed.
5
6
  def self.fail_on_errors(task_descriptions)
6
7
  errs1 = task_descriptions.fetch("failures").map {|f| failure_error(f) }
7
8
  errs2 = task_descriptions.fetch("tasks").map do |task|
@@ -28,18 +29,5 @@ module EcsCompose
28
29
  end
29
30
  end
30
31
 
31
- #:nodoc:
32
- def self.failure_error(failure)
33
- "#{failure.fetch("reason")} (resource: #{failure.fetch("arn")})"
34
- end
35
-
36
- attr_reader :messages
37
-
38
- # Create a new task error with one or more messages.
39
- def initialize(messages)
40
- message = (["Errors running tasks:"] + messages).join("\n- ")
41
- super(message)
42
- @messages = messages
43
- end
44
32
  end
45
33
  end
data/lib/ecs_compose.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "ecs_compose/version"
2
2
  require "ecs_compose/json_generator"
3
3
  require "ecs_compose/ecs"
4
+ require "ecs_compose/deployment_error"
5
+ require "ecs_compose/service_error"
4
6
  require "ecs_compose/task_error"
5
7
  require "ecs_compose/task_definition"
6
8
  require "ecs_compose/manifest"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre12
4
+ version: 0.1.0.pre13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd
@@ -104,9 +104,11 @@ files:
104
104
  - exe/ecs-compose
105
105
  - go-publish.sh
106
106
  - lib/ecs_compose.rb
107
+ - lib/ecs_compose/deployment_error.rb
107
108
  - lib/ecs_compose/ecs.rb
108
109
  - lib/ecs_compose/json_generator.rb
109
110
  - lib/ecs_compose/manifest.rb
111
+ - lib/ecs_compose/service_error.rb
110
112
  - lib/ecs_compose/task_definition.rb
111
113
  - lib/ecs_compose/task_error.rb
112
114
  - lib/ecs_compose/version.rb