panteras_api 0.0.8 → 0.0.9
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/bin/mesos_consul_consistency_check +21 -8
- data/lib/panteras_api/chronos_endpoint.rb +18 -0
- data/lib/panteras_api/docker_host.rb +3 -3
- data/lib/panteras_api/marathon_endpoint.rb +3 -3
- data/lib/panteras_api/mesos_cluster.rb +15 -5
- data/lib/panteras_api/version.rb +1 -1
- data/lib/panteras_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b7de68bc417673c5a3fe9ba5bd159b4d15c05b
|
4
|
+
data.tar.gz: cf67f85241261d9d33f4bf15da8fbc01be723b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b431635a6479b59ebab84056fc7e0ab44944b043f35cbab2b1159671c1598d08115efeae6f7812c4e3439f277b91d67ab39655dc0533f08d9394f069e7cbcad
|
7
|
+
data.tar.gz: 6b4193b5e7f6aafdaebba2137f23f559bfd18cabb6668aaf30c9a222ebd5360d66eaf97cbaf9dbb4d39fce3ba66969953c3a2e6d314bed64314d7fbe54b6ba27
|
@@ -17,7 +17,7 @@ bad_news = []
|
|
17
17
|
good_news = []
|
18
18
|
|
19
19
|
OptionParser.new("Usage: #{$0} [options]") do |opts|
|
20
|
-
opts.release =
|
20
|
+
opts.release = PanterasApi::VERSION
|
21
21
|
|
22
22
|
opts.on("-m", "--mesos-master-hostname MESOS_MASTER_HOSTNAME", "Default: #{config_default[:mesos_master_hostname]}") do |m|
|
23
23
|
options[:mesos_master_hostname] = m
|
@@ -59,7 +59,7 @@ rescue SocketError, Errno::ECONNREFUSED => e
|
|
59
59
|
abort("Problem connecting to mesos host #{config[:mesos_master_hostname]}:#{config[:mesos_master_port]}: #{e.message}")
|
60
60
|
end
|
61
61
|
|
62
|
-
abort("No running mesos tasks seen on mesos master #{config[:mesos_master_hostname]}:#{config[:mesos_master_port]}") if mesos.tasks.
|
62
|
+
abort("No running mesos tasks seen on mesos master #{config[:mesos_master_hostname]}:#{config[:mesos_master_port]}") if mesos.tasks('marathon').size == 0
|
63
63
|
|
64
64
|
puts "#" * 75 if config[:debug]
|
65
65
|
puts "* Mesos tasks ids running this cluster (all slaves):" if config[:debug]
|
@@ -68,7 +68,9 @@ puts mesos.tasks if config[:debug]
|
|
68
68
|
|
69
69
|
puts "#" * 75 if config[:debug]
|
70
70
|
puts "* Mesos tasks ids for tasks running on #{my_fqdn}:" if config[:debug]
|
71
|
-
mesos_tasks = mesos.my_tasks_ids(my_fqdn).flatten
|
71
|
+
mesos_tasks = mesos.my_tasks_ids(my_fqdn, 'marathon').flatten
|
72
|
+
mesos_tasks = mesos_tasks + mesos.my_tasks_ids(my_fqdn, 'chronos-2.4.0').flatten
|
73
|
+
|
72
74
|
puts mesos_tasks if config[:debug]
|
73
75
|
|
74
76
|
good_news << "#{mesos_tasks.size} mesos tasks running." if ! mesos_tasks.empty?
|
@@ -79,13 +81,23 @@ marathon = MarathonEndpoint.new(mesos.master_hostname)
|
|
79
81
|
|
80
82
|
puts "#" * 75 if config[:debug]
|
81
83
|
puts "* Marathon tasks on #{my_fqdn}:" if config[:debug]
|
82
|
-
marathon_tasks = marathon.my_task_ids(my_fqdn)
|
84
|
+
marathon_tasks = marathon.my_task_ids(my_fqdn, 'marathon')
|
83
85
|
puts marathon_tasks if config[:debug]
|
84
86
|
|
85
87
|
good_news << "#{marathon_tasks.size} marathon tasks running."
|
86
88
|
|
89
|
+
|
90
|
+
### CHRONOS
|
91
|
+
chronos = ChronosEndpoint.new(mesos.master_hostname, 4400)
|
92
|
+
|
93
|
+
puts "#" * 75 if config[:debug]
|
94
|
+
puts "* Chrnos tasks on #{my_fqdn}:" if config[:debug]
|
95
|
+
chronos_tasks = chronos.my_task_ids(my_fqdn, 'chronos-2.4.0')
|
96
|
+
puts chronos_tasks if config[:debug]
|
97
|
+
|
87
98
|
## compare mesos tasks (source of truth) with tasks seen in marathon
|
88
99
|
only_in_mesos = mesos_tasks - marathon_tasks
|
100
|
+
chronos_tasks.each {|chronos_task| only_in_mesos.delete_if {|mesos_task| mesos_task.match(chronos_task) }}
|
89
101
|
|
90
102
|
## compare marathon tasks with tasks seen in marathon
|
91
103
|
only_in_marathon = marathon_tasks - mesos_tasks
|
@@ -98,16 +110,16 @@ if ! only_in_marathon.empty?
|
|
98
110
|
bad_news << "marathon tasks not seen in mesos: #{only_in_marathon.join(',')}"
|
99
111
|
end
|
100
112
|
|
113
|
+
|
101
114
|
### CONSUL
|
102
115
|
consul = ConsulCluster.new(mesos.master_hostname)
|
103
116
|
### TODO: test with paas-formatted service names
|
104
117
|
puts "#" * 75 if config[:debug]
|
105
118
|
puts "* Consul services for #{my_fqdn}:" if config[:debug]
|
106
|
-
|
107
|
-
consul_services = consul.my_service_ids.reject { |p| p =~ /panteras/ }.collect { |d| d }.compact.reject { |i| i.empty? }
|
119
|
+
consul_services = consul.my_service_ids
|
108
120
|
puts consul.my_services.join("\n") if config[:debug]
|
109
121
|
|
110
|
-
good_news << "#{
|
122
|
+
good_news << "#{consul.my_services.size} consul services running."
|
111
123
|
|
112
124
|
### set these environment variables here or in shell for testing a remote docker (ie, boot2docker)
|
113
125
|
#ENV['DOCKER_HOST']='tcp://192.168.59.103:2376'
|
@@ -134,10 +146,11 @@ if ! docker_not_mesos.empty?
|
|
134
146
|
bad_news << "docker tasks not seen in mesos: #{docker_not_mesos.join(',')}"
|
135
147
|
end
|
136
148
|
|
149
|
+
good_news << "#{docker_inspect.count { |d| d[:name] if d[:chronos_job] }} chronos task running."
|
137
150
|
good_news << "#{docker_tasks.size} docker tasks running"
|
138
151
|
|
139
152
|
### Compare consul-registered tasks vs docker tasks
|
140
|
-
docker_mesos_ids_no_panteras = docker_inspect.reject { |p| p[:name] =~ /panteras/ }.collect { |d| d[:name] }.compact.reject { |i| i.empty? }
|
153
|
+
docker_mesos_ids_no_panteras = docker_inspect.reject { |p| p[:name] =~ /panteras/ }.collect { |d| d[:name] if ! d[:chronos_job] }.compact.reject { |i| i.empty? }
|
141
154
|
consul_not_docker = consul_services - docker_mesos_ids_no_panteras
|
142
155
|
docker_not_consul = docker_mesos_ids_no_panteras - consul_services
|
143
156
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ChronosEndpoint
|
2
|
+
include HTTPUtils
|
3
|
+
include Utils
|
4
|
+
|
5
|
+
def initialize(host, port=8080)
|
6
|
+
@host = host
|
7
|
+
@port = port
|
8
|
+
end
|
9
|
+
|
10
|
+
def all_apps
|
11
|
+
to_j(get_response_with_redirect(@host, '/scheduler/jobs', @port))
|
12
|
+
end
|
13
|
+
|
14
|
+
def my_task_ids(hostname, framework = 'chronos')
|
15
|
+
all_apps.collect { |a| a[:name][0..-1] }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -25,9 +25,9 @@ class DockerHost
|
|
25
25
|
containers.map do |c|
|
26
26
|
inspect = self.command("docker inspect #{c[:container_id]}")[:output]
|
27
27
|
h = to_j(inspect.join).first
|
28
|
-
task_id = h[:Config][:Env].select { |env| env
|
28
|
+
task_id = h[:Config][:Env].select { |env| env.upcase =~ /MESOS_TASK_ID=/ }.first
|
29
29
|
mesos_task_id = task_id.nil? ? '' : task_id.split(/=/)[1]
|
30
|
-
{ id: h[:Id], image: h[:Image], name: h[:Name][1..-1], mesos_task_id: mesos_task_id }
|
30
|
+
{ id: h[:Id], image: h[:Image], name: h[:Name][1..-1], mesos_task_id: mesos_task_id, chronos_job: h[:Config][:Env].join(',').include?('CHRONOS_JOB_NAME=') ? true : false }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -74,4 +74,4 @@ class DockerHost
|
|
74
74
|
return { :output => output, :error => error}
|
75
75
|
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
@@ -29,12 +29,12 @@ class MarathonEndpoint
|
|
29
29
|
app_names.collect { |n| app(n)[:tasks].select { |t| t[:host] =~ /^#{hostname}$/ } }
|
30
30
|
end
|
31
31
|
|
32
|
-
def my_task_ids(hostname)
|
32
|
+
def my_task_ids(hostname, framework = 'marathon')
|
33
33
|
my_tasks(hostname).collect { |t| t.collect { |a| a[:id] } }.flatten
|
34
|
-
end
|
34
|
+
end
|
35
35
|
|
36
36
|
def task_ids
|
37
37
|
app_names.collect { |a| tasks_ids(a) }
|
38
38
|
end
|
39
39
|
|
40
|
-
end
|
40
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'uri'
|
4
4
|
require 'json'
|
5
|
+
require 'pp'
|
5
6
|
|
6
7
|
class MesosCluster
|
7
8
|
include HTTPUtils
|
@@ -47,8 +48,12 @@ class MesosCluster
|
|
47
48
|
state[:frameworks].collect { |f| f[:completed_tasks].collect { |t| t } }
|
48
49
|
end
|
49
50
|
|
50
|
-
def tasks
|
51
|
-
results = frameworks.collect
|
51
|
+
def tasks(framework = nil)
|
52
|
+
results = frameworks.collect do |a|
|
53
|
+
if a[:name] == framework
|
54
|
+
a[:tasks].collect { |t| t[:slave_hostname] = slave_hostname_by_id(t[:slave_id]) ; t }
|
55
|
+
end
|
56
|
+
end
|
52
57
|
results.reject { |r| r.nil? or r.length == 0 }.first
|
53
58
|
end
|
54
59
|
|
@@ -56,9 +61,14 @@ class MesosCluster
|
|
56
61
|
tasks.collect { |t| t[:id] }
|
57
62
|
end
|
58
63
|
|
59
|
-
def my_tasks_ids(hostname)
|
60
|
-
|
61
|
-
|
64
|
+
def my_tasks_ids(hostname, framework)
|
65
|
+
raise ArgumentError, "missing hostname argument", caller if hostname.nil?
|
66
|
+
new_tasks = tasks(framework)
|
67
|
+
if ! new_tasks.nil?
|
68
|
+
new_tasks.select { |t| t[:slave_hostname] =~ /^#{hostname}$/ }.collect { |t| t[:id] }
|
69
|
+
else
|
70
|
+
new_tasks = []
|
71
|
+
end
|
62
72
|
end
|
63
73
|
|
64
74
|
def resources
|
data/lib/panteras_api/version.rb
CHANGED
data/lib/panteras_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panteras_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Colby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/mesos_consul_consistency_check
|
73
73
|
- bin/mesos_consul_consistency_check_nagios_wrapper
|
74
74
|
- lib/panteras_api.rb
|
75
|
+
- lib/panteras_api/chronos_endpoint.rb
|
75
76
|
- lib/panteras_api/consul_cluster.rb
|
76
77
|
- lib/panteras_api/docker_host.rb
|
77
78
|
- lib/panteras_api/http_utils.rb
|