ecs_deployer 2.1.13 → 2.2.0

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
  SHA256:
3
- metadata.gz: f7b29a6b759c8374e99b6b5c8c513e1e781f5207de52e19613619344d6e396af
4
- data.tar.gz: d49839f00dcb9b254d4ee9a1535cfe4176baa8ce255440ec051ab3510ef7147f
3
+ metadata.gz: 074c9a43276dd4667e47d6177aa20fdfb2b65d85dda2f40c79184b2a2a63d938
4
+ data.tar.gz: b2ed769b0f71267662bbbe9e6c5130498377f2865c1dd933eb1560f4eb3149cb
5
5
  SHA512:
6
- metadata.gz: 5cb81db355611be4b8cb2ca131380f3554d0b8071f4759bbeb87b439939329d09c2b280fd7b8f4142d52d5874e2d5e788d701621fd89038e4609789bcb853693
7
- data.tar.gz: 5eec9fa0df0d9571c15fe073379b9730835c2ba9651394bee233700c3cf63ce5a035445a9998a8ac71cab301e1f62fa5d73194201861c8b589899131658f3194
6
+ metadata.gz: fe22a8d339905fcb4300951a4bf48c502a34d19974ce9c1cc871dcecde0c3140bc6eeed9854dc68bf832e84ac107be6d3b6a64d8f9c8d27deb081be6da3f916e
7
+ data.tar.gz: 1a049a1f2d7d8794fa96b61b30039e19833fca8dfa4ae3559befb4681b7aa95da83c37ff957182a84589569f78aac2444a9b28c817d24f963ee7d1518be1a692
data/README.md CHANGED
@@ -1,9 +1,3 @@
1
- # Release news
2
-
3
- I developed ECS deployment tool based on `ecs_deployer`.
4
-
5
- http://github.com/metaps/genova
6
-
7
1
  # ECS Deployer
8
2
 
9
3
  [![Gem Version](https://badge.fury.io/rb/ecs_deployer.svg)](https://badge.fury.io/rb/ecs_deployer)
@@ -11,9 +5,10 @@ http://github.com/metaps/genova
11
5
  [![Code Climate](https://codeclimate.com/github/naomichi-y/ecs_deployer/badges/gpa.svg)](https://codeclimate.com/github/naomichi-y/ecs_deployer)
12
6
  [![CircleCI](https://circleci.com/gh/naomichi-y/ecs_deployer/tree/master.svg?style=shield)](https://circleci.com/gh/naomichi-y/ecs_deployer/tree/master)
13
7
 
14
- ## Description
8
+ ## Features
15
9
 
16
- Deploy Docker container on AWS ECS.
10
+ This package provides ability to deploy tasks to AWS ECS.
11
+ The library is used by [genova](https://github.com/metaps/genova).
17
12
 
18
13
  * Task
19
14
  * Create
@@ -23,8 +18,6 @@ Deploy Docker container on AWS ECS.
23
18
  * Create
24
19
  * Update
25
20
 
26
- This package is used in [Genova (ECS Deployment Manager)](https://github.com/metaps/genova).
27
-
28
21
  ## Installation
29
22
 
30
23
  Add this line to your application's Gemfile:
@@ -70,7 +63,7 @@ Encrypted values must be enclosed in `${XXX}`.
70
63
  ```yaml
71
64
  - environment:
72
65
  - name: MYSQL_ROOT_PASSWORD
73
- value: ${fiSAIfIFxd...}
66
+ value: ${...}
74
67
  ```
75
68
 
76
69
  Values are decrypted when task is created.
@@ -87,8 +80,6 @@ deployer.register_task('development.yml', tag: 'latest')
87
80
 
88
81
  ### CLI
89
82
 
90
- Please create `.env` from `.env.default` file, before running.
91
-
92
83
  #### Register new task
93
84
 
94
85
  ```bash
@@ -11,6 +11,8 @@ module EcsDeployer
11
11
  @aws_options[:profile] = options[:profile] if options[:profile]
12
12
  @aws_options[:region] = options[:region] if options[:region]
13
13
 
14
+ @logger = Logger.new(STDOUT)
15
+
14
16
  nil
15
17
  end
16
18
 
@@ -37,12 +39,12 @@ module EcsDeployer
37
39
  option :wait, type: :boolean, default: true
38
40
  option :wait_timeout, type: :numeric, default: 600
39
41
  def update_service
40
- deploy_client = EcsDeployer::Client.new(options[:cluster], nil, @aws_options)
42
+ deploy_client = EcsDeployer::Client.new(options[:cluster], @logger, @aws_options)
41
43
  service_client = deploy_client.service
42
44
  service_client.wait_timeout = options[:wait_timeout]
43
45
  result = service_client.update(options[:service], nil, options[:wait])
44
46
 
45
- puts "Update service: #{result.service_arn}"
47
+ puts "Service has been successfully updated: #{result.service_arn}"
46
48
  end
47
49
 
48
50
  desc 'encrypt', 'Encrypt value of argument with KMS.'
@@ -90,25 +90,24 @@ module EcsDeployer
90
90
  desired_status: 'RUNNING'
91
91
  )
92
92
 
93
- raise TaskRunningError, 'Running task not found.' if result[:task_arns].size.zero?
94
-
95
- result = @ecs.describe_tasks(
96
- cluster: @cluster,
97
- tasks: result[:task_arns]
98
- )
99
-
100
- new_running_count = 0
101
- task_status_logs = []
102
-
103
- result[:tasks].each do |task|
104
- new_running_count += 1 if task_definition_arn == task[:task_definition_arn] && task[:last_status] == 'RUNNING'
105
- task_status_logs << " #{task[:task_definition_arn]} [#{task[:last_status]}]"
93
+ new_task_count = 0
94
+ status_logs = []
95
+
96
+ if result[:task_arns].size.positive?
97
+ result = @ecs.describe_tasks(
98
+ cluster: @cluster,
99
+ tasks: result[:task_arns]
100
+ )
101
+
102
+ result[:tasks].each do |task|
103
+ new_task_count += 1 if task_definition_arn == task[:task_definition_arn] && task[:last_status] == 'RUNNING'
104
+ status_logs << " #{task[:task_definition_arn]} [#{task[:last_status]}]"
105
+ end
106
106
  end
107
107
 
108
108
  {
109
- current_running_count: result[:tasks].size,
110
- new_running_count: new_running_count,
111
- task_status_logs: task_status_logs
109
+ new_task_count: new_task_count,
110
+ status_logs: status_logs
112
111
  }
113
112
  end
114
113
 
@@ -118,30 +117,38 @@ module EcsDeployer
118
117
  raise ServiceNotFoundError, "'#{service}' service is not found." unless exist?(service)
119
118
 
120
119
  wait_time = 0
121
- @logger.info 'Start deploying...'
120
+ @logger.info 'Start deployment.'
121
+
122
+ result = @ecs.describe_services(
123
+ cluster: @cluster,
124
+ services: [service]
125
+ )
126
+ desired_count = result[:services][0][:desired_count]
122
127
 
123
128
  loop do
124
129
  sleep(@polling_interval)
125
130
  wait_time += @polling_interval
126
131
  result = deploy_status(service, task_definition_arn)
127
132
 
128
- @logger.info "Deploying... [#{result[:new_running_count]}/#{result[:current_running_count]}] (#{wait_time} seconds elapsed)"
133
+ @logger.info "Updating... [#{result[:new_task_count]}/#{desired_count}] (#{wait_time} seconds elapsed)"
129
134
  @logger.info "New task: #{task_definition_arn}"
130
135
  @logger.info LOG_SEPARATOR
131
136
 
132
- result[:task_status_logs].each do |log|
133
- @logger.info log
134
- end
137
+ if result[:status_logs].count.positive?
138
+ result[:status_logs].each do |log|
139
+ @logger.info log
140
+ end
135
141
 
136
- @logger.info LOG_SEPARATOR
142
+ @logger.info LOG_SEPARATOR
143
+ end
137
144
 
138
- if result[:new_running_count] == result[:current_running_count]
139
- @logger.info "Service update succeeded. [#{result[:new_running_count]}/#{result[:current_running_count]}]"
145
+ if result[:new_task_count] == desired_count
146
+ @logger.info "Service update succeeded. [#{result[:new_task_count]}/#{desired_count}]"
140
147
  @logger.info "New task definition: #{task_definition_arn}"
141
148
 
142
149
  break
143
150
  else
144
- @logger.info 'You can stop process with Ctrl+C. Deployment will continue.'
151
+ @logger.info 'You can stop process with Ctrl+C. Deployment continues in background.'
145
152
 
146
153
  if wait_time > @wait_timeout
147
154
  @logger.info "New task definition: #{task_definition_arn}"
@@ -1,3 +1,3 @@
1
1
  module EcsDeployer
2
- VERSION = '2.1.13'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.13
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2019-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -182,7 +182,6 @@ files:
182
182
  - bin/console
183
183
  - bin/setup
184
184
  - circle.yml
185
- - config.local.yml
186
185
  - config.yml
187
186
  - ecs_deployer.gemspec
188
187
  - example/register_task.rb
data/config.local.yml DELETED
@@ -1,6 +0,0 @@
1
- task_path: ~/Projects/nichigas-sandbox/config/deploy/development.yml
2
- scheduled_task_path: ~/Projects/nichigas-sandbox/config/deploy/development.yml
3
- cluster: sandbox
4
- service: development
5
- scheduled_task_rule: curl
6
- scheduled_task_target_id: worker