kubernetes-health 3.0.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/kubernetes-health.gemspec +2 -2
- data/lib/kubernetes/health/config.rb +13 -0
- data/lib/kubernetes/health/rack_on_migrate.rb +1 -1
- data/lib/kubernetes/health/version.rb +1 -1
- data/lib/puma/kubernetes/app.rb +22 -17
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33187ecbabbca1f845ed61bd7159731e7477d113fa83f319eeeb77e715458f12
|
4
|
+
data.tar.gz: 40059808df7f3f1f91b94f77583ab43a8bb8a6bc41df9794f1345f45b5f4c218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f4e926a7a7d649b723c692f903b8863dc91ba8088e392ea2afeab1666fe20a43d411a56577fff4795ac1538c923cc320e1527a58cfb0da02e886dab62e9f15
|
7
|
+
data.tar.gz: abdc9fe6fcf8a28c508a2508d3e996887a936e125f8817e7a9756c10a24d7dac10c0d6330bb3d623325b8a940d571c37191fd3f0cbe8ccab96e5fddbc4cb5e86
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ This gem allows kubernetes monitoring your app while it is running migrates and
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'kubernetes-health', '~> 3.
|
18
|
+
gem 'kubernetes-health', '~> 3.2'
|
19
19
|
```
|
20
20
|
|
21
21
|
## Enabling puma plugin
|
@@ -127,3 +127,11 @@ Kubernetes::Health::Config.route_liveness = '/liveness'
|
|
127
127
|
Kubernetes::Health::Config.route_readiness = '/readiness'
|
128
128
|
Kubernetes::Health::Config.route_metrics = '/metrics'
|
129
129
|
```
|
130
|
+
|
131
|
+
## Customizing requests logs
|
132
|
+
|
133
|
+
```
|
134
|
+
Kubernetes::Health::Config.request_log_callback = lambda { |req, http_code|
|
135
|
+
Rails.logger.debug "Kubernetes Health: Rack on Migrate - Request: Path: #{req.path_info} / Params: #{req.params} / HTTP Code: #{http_code}" rescue nil
|
136
|
+
}
|
137
|
+
```
|
data/kubernetes-health.gemspec
CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
32
|
spec.add_dependency "rack"
|
33
33
|
spec.add_dependency "rails"
|
34
|
-
spec.add_runtime_dependency 'prometheus-client', '~> 0.
|
35
|
-
spec.add_runtime_dependency 'puma'
|
34
|
+
spec.add_runtime_dependency 'prometheus-client', '~> 0.9.0'
|
35
|
+
spec.add_runtime_dependency 'puma'
|
36
36
|
end
|
@@ -8,6 +8,11 @@ module Kubernetes
|
|
8
8
|
@@route_liveness = '/_liveness'
|
9
9
|
@@route_readiness = '/_readiness'
|
10
10
|
@@route_metrics = '/_metrics'
|
11
|
+
|
12
|
+
@@request_log_callback = lambda { |req, http_code|
|
13
|
+
Rails.logger.debug "Kubernetes Health: Rack on Migrate - Request: Path: #{req.path_info} / Params: #{req.params} / HTTP Code: #{http_code}" rescue nil
|
14
|
+
}
|
15
|
+
|
11
16
|
@@lock_or_wait = lambda { ActiveRecord::Base.connection.execute 'select pg_advisory_lock(123456789123456789);' }
|
12
17
|
@@unlock = lambda { ActiveRecord::Base.connection.execute 'select pg_advisory_unlock(123456789123456789);' }
|
13
18
|
|
@@ -18,6 +23,14 @@ module Kubernetes
|
|
18
23
|
def self.lock_or_wait=(value)
|
19
24
|
@@lock_or_wait = value
|
20
25
|
end
|
26
|
+
|
27
|
+
def self.request_log_callback
|
28
|
+
@@request_log_callback
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.request_log_callback=(value)
|
32
|
+
@@request_log_callback = value
|
33
|
+
end
|
21
34
|
|
22
35
|
def self.unlock
|
23
36
|
@@unlock
|
@@ -11,7 +11,7 @@ module Kubernetes
|
|
11
11
|
else
|
12
12
|
http_code = 404
|
13
13
|
end
|
14
|
-
|
14
|
+
::Kubernetes::Health::Config.request_log_callback.call(req, http_code)
|
15
15
|
[http_code, {}, []]
|
16
16
|
end
|
17
17
|
end
|
data/lib/puma/kubernetes/app.rb
CHANGED
@@ -13,25 +13,30 @@ module Puma
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(_env)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when ::Kubernetes::Health::Config.route_readiness
|
21
|
-
i_am_live = ::Kubernetes::Health::Config.live_if.arity == 0 ? ::Kubernetes::Health::Config.live_if.call : ::Kubernetes::Health::Config.live_if.call(req.params)
|
22
|
-
http_code = i_am_live ? 200 : 503
|
23
|
-
when ::Kubernetes::Health::Config.route_liveness
|
24
|
-
i_am_ready = ::Kubernetes::Health::Config.ready_if.arity == 0 ? ::Kubernetes::Health::Config.ready_if.call : ::Kubernetes::Health::Config.ready_if.call(req.params)
|
25
|
-
http_code = i_am_ready ? 200 : 503
|
26
|
-
when ::Kubernetes::Health::Config.route_metrics
|
27
|
-
http_code = 200
|
28
|
-
@parser.parse JSON.parse(@launcher.stats)
|
16
|
+
begin
|
17
|
+
req = ::Rack::Request.new(_env)
|
18
|
+
type = {}
|
19
|
+
content = []
|
29
20
|
type = { 'Content-Type' => 'text/plain' }
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
case req.path_info
|
22
|
+
when ::Kubernetes::Health::Config.route_liveness
|
23
|
+
i_am_live = ::Kubernetes::Health::Config.live_if.arity == 0 ? ::Kubernetes::Health::Config.live_if.call : ::Kubernetes::Health::Config.live_if.call(req.params)
|
24
|
+
http_code = i_am_live ? 200 : 503
|
25
|
+
when ::Kubernetes::Health::Config.route_readiness
|
26
|
+
i_am_ready = ::Kubernetes::Health::Config.ready_if.arity == 0 ? ::Kubernetes::Health::Config.ready_if.call : ::Kubernetes::Health::Config.ready_if.call(req.params)
|
27
|
+
http_code = i_am_ready ? 200 : 503
|
28
|
+
when ::Kubernetes::Health::Config.route_metrics
|
29
|
+
http_code = 200
|
30
|
+
@parser.parse JSON.parse(@launcher.stats)
|
31
|
+
content = [Prometheus::Client::Formats::Text.marshal(Prometheus::Client.registry)]
|
32
|
+
else
|
33
|
+
http_code = 404
|
34
|
+
end
|
35
|
+
rescue
|
36
|
+
http_code = 500
|
37
|
+
content = []
|
33
38
|
end
|
34
|
-
|
39
|
+
::Kubernetes::Health::Config.request_log_callback.call(req, http_code)
|
35
40
|
[http_code, type, content]
|
36
41
|
end
|
37
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-health
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wagner Caixeta
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.9.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.9.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: puma
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
description: "\n This gem allows kubernetes monitoring your app while it is running
|
112
112
|
migrates and after it started.\n Features:\n * add routes /_readiness and
|
113
113
|
/_liveness on rails stack by default;\n * allow custom checks for /_readiness
|
@@ -145,7 +145,7 @@ files:
|
|
145
145
|
homepage: https://github.com/platbr/kubernetes-health
|
146
146
|
licenses: []
|
147
147
|
metadata: {}
|
148
|
-
post_install_message:
|
148
|
+
post_install_message:
|
149
149
|
rdoc_options: []
|
150
150
|
require_paths:
|
151
151
|
- lib
|
@@ -160,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
163
|
+
rubygems_version: 3.1.4
|
164
|
+
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: This gem allows kubernetes monitoring your app while it is running migrates
|
167
167
|
and after it started.
|