marathon_deploy 0.1.45 → 0.1.46
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 +8 -8
- data/lib/marathon_deploy/deployment.rb +30 -30
- data/lib/marathon_deploy/http_util.rb +23 -9
- data/lib/marathon_deploy/marathon_client.rb +1 -1
- data/lib/marathon_deploy/utils.rb +29 -4
- data/lib/marathon_deploy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjMyZWMxN2MyZDhlYjUzNTUwMWI5NTU3Y2Q3OTFlNDJjMDk3NDY0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWFlYjI5NTgwOGY4YjBhNThkZWM2NDdjMDE1OGFmZDkxOGU2NjA4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUyMjE2NDQxNTNmN2M1MDgyYmQzNmMzNjVhMjg4ZDFkOGQ2ODlmMjBhMjhk
|
10
|
+
MWVjZjdkMGIwZjJkMmY0MzIzYjg1ZTY0MjM4ZGUxZDBjYjk3Zjc3NzJmMjEz
|
11
|
+
YTFkZWE4MWU4YTFiNDU4NjU2NGQ1NTAzZWE1ZmE5OWNhYjYxMjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjJjOWJmMTk0YzcyMzNlMDYzYjBjMDk5NWM4MWMzNGJjNzhiYjg4YWRhNzUz
|
14
|
+
OWQ1MzQ4MzQxMTRjMTQyMzNlZTZlZTRiMDllOWExYmY3Y2U1MzQ0ZDNlNTEx
|
15
|
+
MWI4NTA2NGNmMzYyYTQxYzk3N2E3MGRjYzc4ZTQ3MWJlYjM2MDc=
|
@@ -60,7 +60,7 @@ module MarathonDeploy
|
|
60
60
|
elapsedTime = '%.2f' % (Time.now - startTime)
|
61
61
|
$LOG.info("Deployment with deploymentId #{@deploymentId} ended (Total deployment time #{elapsedTime}s)")
|
62
62
|
end
|
63
|
-
end
|
63
|
+
end
|
64
64
|
end
|
65
65
|
|
66
66
|
def wait_for_application(message = "Deployment of application #{@application.id} in progress")
|
@@ -102,7 +102,7 @@ module MarathonDeploy
|
|
102
102
|
$LOG.debug("Healthy instances running: " + healthy.join(','))
|
103
103
|
break
|
104
104
|
else
|
105
|
-
$LOG.info("#{healthy.size} healthy instances seen, #{@application.instances} healthy instances expected, retrying in
|
105
|
+
$LOG.info("#{healthy.size} healthy instances seen, #{@application.instances} healthy instances expected, retrying in #{HEALTHY_WAIT_RECHECK_INTERVAL}s")
|
106
106
|
end
|
107
107
|
end
|
108
108
|
sleep(HEALTHY_WAIT_RECHECK_INTERVAL)
|
@@ -136,11 +136,10 @@ module MarathonDeploy
|
|
136
136
|
def update_app(force=false)
|
137
137
|
url = @url + MarathonDefaults::MARATHON_APPS_REST_PATH + @application.id
|
138
138
|
url += force ? '?force=true' : ''
|
139
|
-
$LOG.debug("Updating app #{@application.id}
|
139
|
+
$LOG.debug("Updating app #{@application.id} #{url}")
|
140
140
|
response = HttpUtil.put(url,@application.json)
|
141
141
|
@deploymentId = Utils.response_body(response)[:deploymentId]
|
142
142
|
return response
|
143
|
-
|
144
143
|
end
|
145
144
|
|
146
145
|
def rolling_restart
|
@@ -163,20 +162,14 @@ module MarathonDeploy
|
|
163
162
|
# returns an array of taskIds which are alive
|
164
163
|
def get_alive(value)
|
165
164
|
raise ArgumentError, "value must be boolean true or false" unless (!!value == value)
|
166
|
-
state = Array.new
|
167
165
|
if (health_checks_defined?)
|
168
166
|
apps = Array.new
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
break unless apps.nil?
|
176
|
-
$LOG.info "Application #{@application.id} is not yet registered with Marathon. Waiting #{i} seconds then retrying ..."
|
177
|
-
sleep i
|
178
|
-
}
|
179
|
-
|
167
|
+
begin
|
168
|
+
apps = Utils.getValue(@url,@application,:app)
|
169
|
+
rescue Exception=>e
|
170
|
+
$LOG.info "EXCEPTION: #{e} Cannot determine apps"
|
171
|
+
end
|
172
|
+
|
180
173
|
if (apps.nil? or apps.empty?)
|
181
174
|
raise Error::DeploymentError, "Marathon API returned an empty app or nil json object for application #{@application.id}", caller
|
182
175
|
else
|
@@ -208,25 +201,32 @@ module MarathonDeploy
|
|
208
201
|
end
|
209
202
|
return task_ids
|
210
203
|
end
|
211
|
-
|
204
|
+
|
212
205
|
def get_task_ids
|
213
|
-
|
214
|
-
|
215
|
-
|
206
|
+
begin
|
207
|
+
a = Utils.getValue(@url,@application,:app,:tasks).collect { |task| task[:id]}
|
208
|
+
return a
|
209
|
+
rescue Exception=>e
|
210
|
+
$LOG.info "EXCEPTION: #{e} Cannot determine task_ids"
|
211
|
+
end
|
216
212
|
end
|
217
|
-
|
213
|
+
|
218
214
|
def get_healthcheck_results
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
215
|
+
begin
|
216
|
+
a = Utils.getValue(@url,@application,:app,:tasks).collect { |task| task[:healthCheckResults]}
|
217
|
+
return a
|
218
|
+
rescue Exception=>e
|
219
|
+
$LOG.info "EXCEPTION: #{e} Cannot determine healthcheck_result"
|
220
|
+
end
|
223
221
|
end
|
224
222
|
|
225
223
|
def get_deployment_id
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
224
|
+
begin
|
225
|
+
a = Utils.getValue(@url,@application,:app,:deployments,0)[:id]
|
226
|
+
return a
|
227
|
+
rescue Exception=>e
|
228
|
+
$LOG.info "EXCEPTION: #{e} Cannot determine deployment_id"
|
229
|
+
end
|
230
230
|
end
|
231
231
|
|
232
232
|
def list_all
|
@@ -299,4 +299,4 @@ module MarathonDeploy
|
|
299
299
|
end
|
300
300
|
|
301
301
|
end
|
302
|
-
end
|
302
|
+
end
|
@@ -5,15 +5,22 @@ require 'marathon_deploy/error'
|
|
5
5
|
module MarathonDeploy
|
6
6
|
module HttpUtil
|
7
7
|
|
8
|
+
@@o_timeout = 60.0
|
9
|
+
@@r_timeout = 60.0
|
10
|
+
@@og_timeout = 60.0
|
11
|
+
@@rg_timeout = 60.0
|
12
|
+
|
8
13
|
def self.put(url,payload)
|
9
14
|
uri = construct_uri url
|
10
15
|
begin
|
11
16
|
http = Net::HTTP.new(uri.host, uri.port)
|
17
|
+
http.open_timeout = @@o_timeout
|
18
|
+
http.read_timeout = @@r_timeout
|
12
19
|
req = Net::HTTP::Put.new(uri.request_uri)
|
13
20
|
req.body = payload.to_json
|
14
21
|
req["Content-Type"] = "application/json"
|
15
22
|
response = http.request(req)
|
16
|
-
rescue
|
23
|
+
rescue Exception => e
|
17
24
|
$LOG.error("Error calling marathon api: #{e.message}")
|
18
25
|
exit!
|
19
26
|
end
|
@@ -24,11 +31,13 @@ module MarathonDeploy
|
|
24
31
|
uri = construct_uri url
|
25
32
|
begin
|
26
33
|
http = Net::HTTP.new(uri.host, uri.port)
|
34
|
+
http.open_timeout = @@o_timeout
|
35
|
+
http.read_timeout = @@r_timeout
|
27
36
|
req = Net::HTTP::Post.new(uri.request_uri)
|
28
37
|
req.body = payload.to_json
|
29
38
|
req["Content-Type"] = "application/json"
|
30
39
|
response = http.request(req)
|
31
|
-
rescue
|
40
|
+
rescue Exception => e
|
32
41
|
message = "Error calling marathon api: #{e.message}"
|
33
42
|
$LOG.error(message)
|
34
43
|
raise Error::MarathonError, message, caller
|
@@ -45,9 +54,11 @@ module MarathonDeploy
|
|
45
54
|
uri = construct_uri url
|
46
55
|
begin
|
47
56
|
http = Net::HTTP.new(uri.host, uri.port)
|
57
|
+
http.open_timeout = @@o_timeout
|
58
|
+
http.read_timeout = @@r_timeout
|
48
59
|
req = Net::HTTP::Delete.new(uri.request_uri)
|
49
60
|
response = http.request(req)
|
50
|
-
rescue
|
61
|
+
rescue Exception => e
|
51
62
|
message = "Error calling marathon api: #{e.message}"
|
52
63
|
$LOG.error(message)
|
53
64
|
raise Error::MarathonError, message, caller
|
@@ -62,11 +73,14 @@ module MarathonDeploy
|
|
62
73
|
def self.get(url)
|
63
74
|
uri = construct_uri url
|
64
75
|
begin
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
76
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
77
|
+
http.open_timeout = @@og_timeout
|
78
|
+
http.read_timeout = @@rg_timeout
|
79
|
+
# http.set_debug_output($stdout)
|
80
|
+
req = Net::HTTP::Get.new(uri.request_uri)
|
81
|
+
req["Content-Type"] = "application/json"
|
82
|
+
response = http.request(req)
|
83
|
+
rescue Exception => e
|
70
84
|
message = "Error calling marathon api: #{e.message}"
|
71
85
|
$LOG.error(message)
|
72
86
|
raise Error::MarathonError, message, caller
|
@@ -90,4 +104,4 @@ module MarathonDeploy
|
|
90
104
|
end
|
91
105
|
|
92
106
|
end
|
93
|
-
end
|
107
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'marathon_deploy/marathon_defaults'
|
2
|
+
|
1
3
|
module MarathonDeploy
|
2
4
|
module Utils
|
3
5
|
|
@@ -23,11 +25,34 @@ module MarathonDeploy
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.response_body(response)
|
26
|
-
if (response.
|
27
|
-
|
28
|
+
if (!response.body.nil? && !response.body.empty? && response.kind_of?(Net::HTTPSuccess))
|
29
|
+
begin
|
30
|
+
return deep_symbolize((JSON.parse(response.body)))
|
31
|
+
rescue Exception=>e
|
32
|
+
$LOG.info "EXCEPTION: #{e} Cannot parse JSON"
|
33
|
+
end
|
28
34
|
end
|
29
35
|
return nil
|
30
36
|
end
|
31
|
-
|
37
|
+
|
38
|
+
def self.getValue(url,application,*keys)
|
39
|
+
value = nil
|
40
|
+
5.times { |i|
|
41
|
+
i+=1
|
42
|
+
model = response_body(HttpUtil.get(url + MarathonDefaults::MARATHON_APPS_REST_PATH + application.id))
|
43
|
+
value = lookup(model, *keys) if (!model.nil? and !model.empty?)
|
44
|
+
break if (!value.nil? and !value.empty?)
|
45
|
+
$LOG.info "Application #{application.id} is not yet registered with Marathon. Waiting #{i} seconds then retrying ..."
|
46
|
+
sleep i
|
47
|
+
}
|
48
|
+
value
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.lookup(model, key, *rest)
|
52
|
+
v = model[key]
|
53
|
+
return v if rest.empty?
|
54
|
+
v && lookup(v, *rest)
|
55
|
+
end
|
56
|
+
|
32
57
|
end
|
33
|
-
end
|
58
|
+
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.1.
|
4
|
+
version: 0.1.46
|
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-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger
|