marathon-template 0.0.11 → 0.0.12
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/marathon-template/deploy.rb +34 -32
- data/lib/marathon_template.rb +2 -0
- 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: 68b6f9cdb9860cd1b0311093eab0718f3e64546d
|
4
|
+
data.tar.gz: 36b0e90716e2fb365618f47aba97a21abe944609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04afaedf48626b35ecce06a296e5c8a7473d84768be74f664cd30a21976b3ac1a126f84596ac1627d9480d5d0677b63d5956d47e6fbad0ffa1c6259f9fa3eb8a
|
7
|
+
data.tar.gz: e82b4dfd4e6f96ff9172c0790eba89ce53a4267ed36c090d774220a707be5c658a8ef5b141c6f058ad46fd50ee75061cdffdc441a2518132a84dddbccc1b575c
|
@@ -106,7 +106,10 @@ module Marathon_template
|
|
106
106
|
app_name = values['app_name']
|
107
107
|
options = values['options']
|
108
108
|
servers = get_servers(app_name)
|
109
|
-
if
|
109
|
+
if servers['404'] #== '404'
|
110
|
+
LOG.info servers
|
111
|
+
LOG.info "#{app_name} was not found in Marathon, skipping but continuing to manage the haproxy.cfg"
|
112
|
+
elsif values['management_port']
|
110
113
|
LOG.info "#{app_name}: #{servers}"
|
111
114
|
servers.each do |host, port|
|
112
115
|
f.write "\tserver #{app_name}-#{host.split('_').last} #{host.split('_').first}:#{port[0]} #{options} port #{port[1]}\n"
|
@@ -134,39 +137,38 @@ module Marathon_template
|
|
134
137
|
end
|
135
138
|
|
136
139
|
def self.get_servers(app_name)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
else
|
159
|
-
if response.code == '404'
|
160
|
-
abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}\n Are you sure the app #{app_name} exists?"
|
161
|
-
else
|
162
|
-
abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}"
|
163
|
-
end
|
140
|
+
LOG.info "Getting host and port assignments for #{app_name}..."
|
141
|
+
# Setup the URI for marathon and check it before moving on
|
142
|
+
marathon_app = "#{CONFIG[:marathon]}/v2/apps/#{app_name}"
|
143
|
+
unless URI.parse(URI.encode(marathon_app))
|
144
|
+
abort LOG.info "The URI for #{marathon_app} doesn't look right."
|
145
|
+
end
|
146
|
+
LOG.info "Querying #{marathon_app}"
|
147
|
+
# Parse the URI for reals and make a request
|
148
|
+
encoded_uri = URI.encode(marathon_app.to_s)
|
149
|
+
uri = URI.parse(encoded_uri)
|
150
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
151
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
152
|
+
response = http.request(request)
|
153
|
+
return_hash = Hash.new
|
154
|
+
# If we get a 200, lets return the servier hosts and ports assignments
|
155
|
+
if response.code == '200'
|
156
|
+
json = JSON.parse(response.body)
|
157
|
+
tasks = json['app']['tasks']
|
158
|
+
tasks.each_with_index do |task, i|
|
159
|
+
LOG.info "Found host #{task['host']} and port #{task['ports']}"
|
160
|
+
return_hash["#{task['host']}_#{i}"] = task['ports']
|
164
161
|
end
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
162
|
+
# If we don't then do not blow up, simply return not found and move on. This way usable servers still get proxied.
|
163
|
+
elsif response.code == '404'
|
164
|
+
LOG.warn "Response code: #{response.code}"
|
165
|
+
LOG.warn "Are you sure the app #{app_name} exsts?"
|
166
|
+
return_hash[response.code] = 'not_found'
|
167
|
+
LOG.info return_hash
|
168
|
+
else
|
169
|
+
abort LOG.error "Got #{response.code} which is neither 404 or 200"
|
169
170
|
end
|
171
|
+
return_hash
|
170
172
|
end
|
171
173
|
|
172
174
|
def self.test_haproxy_dir
|
data/lib/marathon_template.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marathon-template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Malnick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|