kubernetes_health_checker 0.0.0.15 → 0.0.0.19
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/kubernetes_health_checker +36 -28
- data/bin/kubernetes_health_checkerd +2 -2
- data/bin/mock_output.txt +4 -4
- data/bin/mock_output_two.txt +3 -3
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d25309097896471d9d14d0a5b6a93dcb4d4fd854bcc551ce701b698d6b3238e
|
4
|
+
data.tar.gz: fa80370d7d7c083668965e35d660d39cc68fbdae9cad9f923400274cc626af15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452102d69202d30e85f7ebdd6cc52f9f99b6376e3cb534847ee609314c5c3a7744e5b45b56b9d9cab09b47d04482f5affb93110bbf0513b6bfa145fe4e9a04c5
|
7
|
+
data.tar.gz: 1f9f93cdbc6de8481265f992e9d033f7b45d0e9ce73d6cb96a33b50768a0a14d50dc80faaa0652a59c38756a46025d51185919dbf1d2d44582e9b5ec28e05d0c
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'thor'
|
5
5
|
require 'json'
|
6
|
+
require 'syslog/logger'
|
6
7
|
|
7
8
|
module KubernetesHealthChecker
|
8
9
|
class Runner < Thor
|
@@ -15,46 +16,51 @@ module KubernetesHealthChecker
|
|
15
16
|
method_option :url, aliases: '-u', type: :string, desc: 'Specify the slack url you would like the alert POSTed to'
|
16
17
|
method_option :test, aliases: '-t', type: :boolean, desc: 'Specify if running the gem in test mode'
|
17
18
|
|
18
|
-
ALERT_STATUSES = [
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
].freeze
|
19
|
+
ALERT_STATUSES = %w[crashloopbackoff
|
20
|
+
error
|
21
|
+
runcontainererror
|
22
|
+
createcontainerconfigerror
|
23
|
+
oomkilled].freeze
|
24
24
|
|
25
25
|
# time is in seconds
|
26
26
|
TIMED_ALERT_STATUSES = {
|
27
27
|
'pending' => 120,
|
28
|
-
'
|
29
|
-
|
28
|
+
'errimagepull' => 120,
|
29
|
+
'containercreating' => 120
|
30
|
+
}.freeze
|
30
31
|
|
31
32
|
RUN_INTERVAL = 10
|
32
33
|
|
33
34
|
def start
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
log = Syslog::Logger.new 'kubernetes_health_checker'
|
36
|
+
|
37
|
+
begin
|
38
|
+
set_defaults(options)
|
39
|
+
run_validations if !@test
|
40
|
+
while true
|
41
|
+
puts 'starting...'
|
42
|
+
output = get_cli_output
|
43
|
+
message = construct_message(output)
|
44
|
+
send_alert(message) if !message.empty?
|
45
|
+
puts 'sleeping...'
|
46
|
+
sleep RUN_INTERVAL
|
47
|
+
end
|
48
|
+
rescue => e
|
49
|
+
log.error(e)
|
43
50
|
end
|
44
51
|
end
|
45
52
|
|
46
53
|
desc 'version', 'Prints version'
|
47
54
|
def version
|
48
|
-
say
|
55
|
+
say 'KubernetesHealthChecker 0.0.0'
|
49
56
|
end
|
50
57
|
|
51
58
|
no_commands do
|
52
59
|
def set_defaults(options)
|
53
|
-
opts = options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
60
|
+
opts = options.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
|
54
61
|
@alert_threshold = opts[:alert_threshold] || 5
|
55
62
|
@slack_channel = opts[:channel] || '@rohan'
|
56
|
-
|
57
|
-
@namespace = opts[:namespace].split(',') || ['default']
|
63
|
+
@namespace = opts[:namespace]&.split(',') || ['default']
|
58
64
|
@test = opts[:test] || false
|
59
65
|
@url = opts[:url]
|
60
66
|
@pods_data = {}
|
@@ -68,7 +74,7 @@ module KubernetesHealthChecker
|
|
68
74
|
if @test
|
69
75
|
# so hacky, but pulls from second mock output if
|
70
76
|
# it's the second time running to test state changes
|
71
|
-
file_name = @pods_data.empty? ? '../mock_output.txt' : '../
|
77
|
+
file_name = @pods_data.empty? ? '../mock_output.txt' : '../mock_output_two.txt'
|
72
78
|
path = File.expand_path(file_name, __FILE__)
|
73
79
|
output = File.read(path)
|
74
80
|
else
|
@@ -89,7 +95,7 @@ module KubernetesHealthChecker
|
|
89
95
|
channel: @slack_channel,
|
90
96
|
username: 'kubernetes_health_check_bot',
|
91
97
|
text: message,
|
92
|
-
icon_emoji:
|
98
|
+
icon_emoji: ':face_with_thermometer:'
|
93
99
|
}
|
94
100
|
|
95
101
|
`curl -X POST --data-urlencode 'payload=#{JSON.generate(payload)}' #{@url}`
|
@@ -98,7 +104,7 @@ module KubernetesHealthChecker
|
|
98
104
|
def get_pod_message(pod_name:, new_status:, new_restarts:, age:)
|
99
105
|
old_restarts = @pods_data[pod_name][:restarts]
|
100
106
|
old_status = @pods_data[pod_name][:status]
|
101
|
-
text =
|
107
|
+
text = ''
|
102
108
|
|
103
109
|
if !@pods_data[pod_name].empty? && old_restarts == new_restarts && old_status == new_status
|
104
110
|
# we've already alerted from this state, skip
|
@@ -118,20 +124,22 @@ module KubernetesHealthChecker
|
|
118
124
|
|
119
125
|
def construct_message(output)
|
120
126
|
message = ''
|
121
|
-
new_pod_store = {}
|
122
127
|
|
123
128
|
rows = output.split("\n")
|
124
129
|
rows.each_with_index do |row, index|
|
125
130
|
next if index == 0
|
126
131
|
|
127
|
-
row = row.split(
|
132
|
+
row = row.split(' ')
|
128
133
|
pod_name = row[0]
|
129
134
|
status = row[2]
|
130
135
|
restarts = row[3].to_i
|
131
136
|
age = get_age_in_seconds(row[4])
|
132
137
|
|
133
138
|
@pods_data[pod_name] ||= {}
|
134
|
-
message += get_pod_message(pod_name: pod_name,
|
139
|
+
message += get_pod_message(pod_name: pod_name,
|
140
|
+
new_status: status,
|
141
|
+
new_restarts: restarts,
|
142
|
+
age: age)
|
135
143
|
|
136
144
|
# update our data store for the pods
|
137
145
|
@pods_data[pod_name][:status] = status
|
@@ -162,4 +170,4 @@ module KubernetesHealthChecker
|
|
162
170
|
end
|
163
171
|
end
|
164
172
|
|
165
|
-
KubernetesHealthChecker::Runner.start
|
173
|
+
KubernetesHealthChecker::Runner.start
|
data/bin/mock_output.txt
CHANGED
@@ -6,7 +6,7 @@ affinity-external-api-dep-1624144290-zqsfb 0/2 Evicted 0
|
|
6
6
|
affinity-external-api-dep-3283253972-ttgft 2/2 Running 0 1d
|
7
7
|
automate-affinity-pipeline-rc-l6zb0 1/1 Running 0 1d
|
8
8
|
compute-relationship-strengths-rc-x8mv1 1/1 Running 0 1d
|
9
|
-
convert-html-to-text-consumer-rc-lx0s5 1/1
|
9
|
+
convert-html-to-text-consumer-rc-lx0s5 1/1 Pending 0 1d
|
10
10
|
create-contacts-consumer-rc-h5hj7 1/1 Running 0 1d
|
11
11
|
create-deal-emails-consumer-rc-qd7n4 1/1 Running 10 22h
|
12
12
|
create-smart-alert-notifications-rc-d87p2 1/1 Running 0 1d
|
@@ -19,8 +19,8 @@ ditto2-rc-ffj0s 1/1 Running 3
|
|
19
19
|
ditto3-rc-ntdz9 1/1 Running 1 22h
|
20
20
|
dump-new-persons-for-labeling-rc-p043f 1/1 Running 0 1d
|
21
21
|
extract-introductions-consumer-rc-32d29 1/1 Running 1 1d
|
22
|
-
extract-signatures-consumer-rc-4n0wl 1/1
|
23
|
-
fetch-public-metadata-rc-g94b0 1/1
|
22
|
+
extract-signatures-consumer-rc-4n0wl 1/1 ErrImagePull 0 60s
|
23
|
+
fetch-public-metadata-rc-g94b0 1/1 ErrImagePull 0 130s
|
24
24
|
health-check-rc-wkh2t 1/1 Running 0 22h
|
25
25
|
helper-rc-17pmz 1/1 Running 0 22h
|
26
26
|
import-companies-rc-grkkm 1/1 Running 0 1d
|
@@ -104,4 +104,4 @@ weave-net-h29cn 2/2 R
|
|
104
104
|
weave-net-mqjcw 2/2 Running 4 68d
|
105
105
|
weave-net-r85qh 2/2 Running 0 2h
|
106
106
|
weave-net-wgsml 2/2 Running 12 68d
|
107
|
-
weave-net-zdz7j 2/2 Running 4 19d
|
107
|
+
weave-net-zdz7j 2/2 Running 4 19d
|
data/bin/mock_output_two.txt
CHANGED
@@ -25,7 +25,7 @@ health-check-rc-wkh2t 1/1 Running 0
|
|
25
25
|
helper-rc-17pmz 1/1 Running 0 22h
|
26
26
|
import-companies-rc-grkkm 1/1 Running 0 1d
|
27
27
|
import-company-metadata-rc-n094g 1/1 Running 0 22h
|
28
|
-
import-crunchbase-metadata-rc-94433 1/1
|
28
|
+
import-crunchbase-metadata-rc-94433 1/1 OOMKilled 0 1d
|
29
29
|
import-person-metadata-rc-wkvrg 1/1 Running 0 1d
|
30
30
|
match-email-to-persons-consumer-rc-l6cgr 1/1 Running 0 22h
|
31
31
|
match-event-to-persons-consumer-rc-w8jn1 1/1 Running 2 1d
|
@@ -54,7 +54,7 @@ send-inactive-user-emails-rc-92pf0 1/1 CrashLoopBackO
|
|
54
54
|
send-weekly-summary-email-rc-vmr8s 1/1 Running 0 1d
|
55
55
|
shoryuken-ews-syncer-rc-rr512 1/1 Running 1 1d
|
56
56
|
shoryuken-ews-syncer-rc-wq76w 1/1 Running 1 1d
|
57
|
-
shoryuken-insert-emails-rc-65ct6 1/1
|
57
|
+
shoryuken-insert-emails-rc-65ct6 1/1 Pending 2 1d
|
58
58
|
sidekiq-rc-kz4tc 1/1 Running 0 1d
|
59
59
|
sidekiq-rc-wl7pm 1/1 Running 0 1d
|
60
60
|
sidekiq-web-dep-1155096845-kfs0h 2/2 Running 0 1d
|
@@ -67,4 +67,4 @@ update-dropped-email-alerts-consumer-rc-n3069 1/1 Running 1
|
|
67
67
|
update-email-count-rc-s29lk 1/1 Running 0 1d
|
68
68
|
update-primary-emails-rc-6sd8b 1/1 Running 0 1d
|
69
69
|
update-sources-consumer-rc-zrf2f 1/1 Running 0 22h
|
70
|
-
vacuum-analyze-db-rc-jr14r 1/1 Running 0 1d
|
70
|
+
vacuum-analyze-db-rc-jr14r 1/1 Running 0 1d
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes_health_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rohan Sahai
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: daemons
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -65,11 +65,11 @@ files:
|
|
65
65
|
- bin/kubernetes_health_checkerd
|
66
66
|
- bin/mock_output.txt
|
67
67
|
- bin/mock_output_two.txt
|
68
|
-
homepage:
|
68
|
+
homepage: https://rubygems.org/gems/kubernetes_health_checker
|
69
69
|
licenses:
|
70
70
|
- MIT
|
71
71
|
metadata: {}
|
72
|
-
post_install_message:
|
72
|
+
post_install_message:
|
73
73
|
rdoc_options: []
|
74
74
|
require_paths:
|
75
75
|
- lib
|
@@ -77,16 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '2.4'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
87
|
+
rubygems_version: 3.2.3
|
88
|
+
signing_key:
|
90
89
|
specification_version: 4
|
91
90
|
summary: Get notifications for unhealthy kubernetes pods
|
92
91
|
test_files: []
|