marathon_deploy 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 2064827ef363519d13290fa9e84e34b37d15a954
4
- data.tar.gz: 9bb6235b0c8b3421cb3904561a67d022a6a72f5d
3
+ metadata.gz: 35b3f25c8764a73dd299377a082c1bf279574ba3
4
+ data.tar.gz: f8db464c0a0165b0f16de1bda5c170b07c069e60
5
5
  SHA512:
6
- metadata.gz: 652ed65844e48852e55d1eb8a69436ab042df65139c0c7af24c3d34f94008a511c6275a68aaf6e94499a01bceba4dfdf3e00149484350b2cb6b7dab10a461651
7
- data.tar.gz: 7be0be184f7d07d62e2457965e1d1723a03fa926c0bb6e633b5b1f970d8e359ed81e42b18dafb122f4b5b02add40d87d76e29fbf23ff6e43bcf115948560af7d
6
+ metadata.gz: 77cdd112a5424d33c3188391194ae099090ed7bd15b6a3e97ccdf20d0b42517491b5342a51ddba7288b481413e319b84a281c45277b244f822ce1c182990c7a9
7
+ data.tar.gz: cbee096acc67009a5b7183fc2eeb7a04890c94f54f09e1f715f43b47e27496f621132d0f8b1d37b60a33d38e0ad3280c2bbd3627ffccd2b232e921ce4984d4fe
@@ -0,0 +1,32 @@
1
+ ---
2
+ id: python-example-stable
3
+ cmd: echo python stable `hostname` > index.html; python3 -m http.server 8080
4
+ mem: 16
5
+ cpus: 0.1
6
+ instances: 5
7
+ container:
8
+ type: DOCKER
9
+ docker:
10
+ image: ubuntu:14.04
11
+ network: BRIDGE
12
+ portMappings:
13
+ - containerPort: 8080
14
+ hostPort: 0
15
+ protocol: tcp
16
+ env:
17
+ SERVICE_TAGS: python,webapp,http,weight=100
18
+ SERVICE_NAME: python
19
+ healthChecks:
20
+ - portIndex: 0
21
+ protocol: TCP
22
+ gracePeriodSeconds: 30
23
+ intervalSeconds: 10
24
+ timeoutSeconds: 30
25
+ maxConsecutiveFailures: 3
26
+ - path: "/"
27
+ portIndex: 0
28
+ protocol: HTTP
29
+ gracePeriodSeconds: 30
30
+ intervalSeconds: 10
31
+ timeoutSeconds: 30
32
+ maxConsecutiveFailures: 3
@@ -22,7 +22,7 @@ module MarathonDeploy
22
22
  case extension
23
23
  when '.json'
24
24
  @json = YamlJson.read_json(deployfile)
25
- when '.yaml'
25
+ when '.yaml','.yml'
26
26
  @json = YamlJson.yaml2json(deployfile)
27
27
  else
28
28
  message = "File extension #{extension} is not supported for deployment file #{deployfile}"
@@ -89,13 +89,13 @@ module MarathonDeploy
89
89
  Timeout::timeout(HEALTHY_WAIT_TIMEOUT) do
90
90
  loop do
91
91
  break if (!health_checks_defined?)
92
- sick = get_alive("false")
92
+ sick = get_alive(false)
93
93
  elapsedTime = '%.2f' % (Time.now - startTime)
94
94
  if (!sick.empty?)
95
95
  $LOG.info("#{sick.size}/#{@application.instances} instances are not healthy, retrying in #{HEALTHY_WAIT_RECHECK_INTERVAL}s (elapsed time #{elapsedTime}s)")
96
96
  $LOG.debug("Sick instances: " + sick.join(','))
97
- else
98
- healthy = get_alive("true")
97
+ else
98
+ healthy = get_alive(true)
99
99
  if (healthy.size == @application.instances)
100
100
  elapsedTime = '%.2f' % (Time.now - startTime)
101
101
  $LOG.info("#{healthy.size} of #{@application.instances} expected instances are healthy (Total health-check time #{elapsedTime}s).")
@@ -160,28 +160,43 @@ module MarathonDeploy
160
160
  ####### PRIVATE METHODS ##########
161
161
  private
162
162
 
163
- def get_alive(value)
164
- state = Array.new
165
-
163
+ # returns an array of taskIds which are alive
164
+ def get_alive(value)
165
+ raise ArgumentError, "value must be boolean true or false" unless (!!value == value)
166
+ state = Array.new
166
167
  if (health_checks_defined?)
167
168
  response = list_app
168
169
  response_body = Utils.response_body(response)
169
170
  if (response_body[:app].empty?)
170
171
  raise Error::DeploymentError, "Marathon returned an empty app json object", caller
171
172
  else
172
- get_healthcheck_results.flatten.each do |result|
173
- next if result.nil?
174
- alive = result[:alive].to_s
175
- taskId = result[:taskId].to_s
176
- if (!alive.nil? && !taskId.nil?)
177
- state << taskId if (alive == value)
178
- end
173
+ tasks = Hash.new
174
+ task_ids = Array.new
175
+ check_results = get_healthcheck_results.flatten
176
+ check_results.each do |task|
177
+ next if task.nil?
178
+ tasks[task[:taskId].to_s] ||= []
179
+ tasks[task[:taskId].to_s] << task[:alive]
180
+ end
181
+
182
+ tasks.each do |k,v|
183
+ if (value)
184
+ # if there are only alive=true for all healthchecks for this instance
185
+ if (v.uniq.length == 1 && v.uniq.first == value)
186
+ task_ids << k
187
+ end
188
+ else
189
+ # if alive=false is seen for any healthchecks for this instance
190
+ if (v.include?(value))
191
+ task_ids << k
192
+ end
193
+ end
179
194
  end
180
195
  end
181
196
  else
182
197
  $LOG.info("No health checks defined. Cannot determine application health of #{@application.id}.")
183
198
  end
184
- return state
199
+ return task_ids
185
200
  end
186
201
 
187
202
  def get_task_ids
@@ -193,6 +208,7 @@ module MarathonDeploy
193
208
  def get_healthcheck_results
194
209
  response = list_app
195
210
  response_body = Utils.response_body(response)
211
+ #puts JSON.pretty_generate(response_body)
196
212
  return response_body[:app][:tasks].collect { |task| task[:healthCheckResults]}
197
213
  end
198
214
 
@@ -48,7 +48,7 @@ module MarathonDeploy
48
48
  def self.expand_macros(data)
49
49
  processed = ""
50
50
  macros = get_macros(data).uniq
51
- $LOG.debug("Macros found in deploy file: #{macros.join(',')}")
51
+ $LOG.debug("Macros found in deploy file: #{macros.join(',')}") unless (macros.empty?)
52
52
  undefined = get_undefined_macros(macros)
53
53
  if (!undefined.empty?)
54
54
  raise Error::UndefinedMacroError, "Macros found in deploy file without defined environment variables: #{undefined.join(',')}", caller
@@ -7,7 +7,7 @@ module MarathonDeploy
7
7
 
8
8
  DEPLOYMENT_RECHECK_INTERVAL = 3
9
9
  DEPLOYMENT_TIMEOUT = 300
10
- HEALTHY_WAIT_TIMEOUT = 10 #300
10
+ HEALTHY_WAIT_TIMEOUT = 300
11
11
  HEALTHY_WAIT_RECHECK_INTERVAL = 3
12
12
  PRODUCTION_ENVIRONMENT_NAME = 'PRODUCTION'
13
13
  DEFAULT_ENVIRONMENT_NAME = 'INTEGRATION'
@@ -1,3 +1,3 @@
1
1
  module MarathonDeploy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathon_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Colby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -91,6 +91,7 @@ files:
91
91
  - examples/nohealthchecks.yaml
92
92
  - examples/public-search-germany-webapp.pre.json
93
93
  - examples/run.sh
94
+ - examples/simple-python-example.yaml
94
95
  - examples/testout.json
95
96
  - examples/testout.yaml
96
97
  - input.txt
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  version: '0'
128
129
  requirements: []
129
130
  rubyforge_project:
130
- rubygems_version: 2.4.5
131
+ rubygems_version: 2.4.6
131
132
  signing_key:
132
133
  specification_version: 4
133
134
  summary: Mesos/Marathon deployment tool.