kubernetes-health 3.10.1 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b3784236c03b3d08c9509f94da9e16cb0fb29f642f678684b20ef03d0b56a23
4
- data.tar.gz: 3dd137f774090002773184febbd91ee0a520e4cd76cb414f74b113f96fe19473
3
+ metadata.gz: 588adb5d1b5a937a87c4c71f9b98902faee308d64b679df40784bbf66a7a8cc1
4
+ data.tar.gz: ebecbf287f66d584e48b22cbf038dd042cb32bfc7dde3be298c9cc87766ed0fe
5
5
  SHA512:
6
- metadata.gz: b49429f971fad38a11dc3a65cca1553b8e7bc7463f2ca24b3a85d31d59e95506fcf79f6fbbe17cf2efade3e234b29556839171b0a5fec0791adb0456fcb313bc
7
- data.tar.gz: 5d1f22d376003de55156937fb7449ae2f233a5c8f4a0ff1956c72f0f41cd773101ffb1b335d1ba1c33c1ea4d88186e7089c5589428a2ee3c0ebfc3345bee14ef
6
+ metadata.gz: cd730152d639adbf4402234873b77c00573a61c4c56c8d8ccfd2868518bba40fb3fa0fd7245e38543b52bed32c92647ce4d875af16d9af08bd2f93ae2ee92a4a
7
+ data.tar.gz: 9862d03e7c574cdb148473f47ce872f8a83c072fd28f49e7e0fec1c8e4ccd073edfaf1eb4d0b77077299e79ed2f6a56105c7189cc6fdea1f99543062b5886dc5
data/README.md CHANGED
@@ -16,7 +16,7 @@ This gem open a HTTP port for monitoring your rails app while it is running Migr
16
16
  Add this line to your application's Gemfile:
17
17
 
18
18
  ```ruby
19
- gem 'kubernetes-health', '~> 3.6'
19
+ gem 'kubernetes-health', '~> 3.7'
20
20
  ```
21
21
 
22
22
  ## Enabling puma plugin
@@ -62,7 +62,7 @@ or add in your `application.rb`.
62
62
  # default: false
63
63
  Kubernetes::Health::Config.enable_rack_on_migrate = true
64
64
  ```
65
- The defined port at `config/puma.rb` will be used.
65
+ The defined port at `config/puma.rb` will be used but can be overrided by `KUBERNETES_HEALTH_METRICS_PORT` env var.
66
66
 
67
67
  ## Enabling monitoring for `sidekiq`
68
68
 
@@ -74,7 +74,7 @@ or add in your `application.rb`.
74
74
  # default: false
75
75
  Kubernetes::Health::Config.enable_rack_on_sidekiq = true
76
76
  ```
77
- The defined port at `config/puma.rb` will be used.
77
+ The defined port at `config/puma.rb` will be used but can be overrided by `KUBERNETES_HEALTH_METRICS_PORT` env var.
78
78
 
79
79
  ### How `rake db:migrate` and `sidekiq` monitoring works
80
80
  It will run a RACK server for `/_readiness`, `/_liveness` and `/_metrics`.
@@ -2,6 +2,6 @@ require 'kubernetes/health/rack_on_sidekiq'
2
2
 
3
3
  if Kubernetes::Health::Config.enable_rack_on_sidekiq && Kubernetes::Health::SidekiqOptionsResolver[:concurrency].positive?
4
4
  Thread.new do
5
- Rack::Handler.default.run Kubernetes::Health::RackOnSidekiq.new
5
+ Rack::Handler::WEBrick.run Kubernetes::Health::RackOnSidekiq.new, { Port: Kubernetes::Health::Config.metrics_port }
6
6
  end
7
7
  end
@@ -1,8 +1,10 @@
1
1
  module Kubernetes
2
2
  module Health
3
3
  class Config
4
+ METRICS_PORT_FROM_PUMA_CONFIG = File.read(File.join(Rails.root, 'config', 'puma.rb')).match(/kubernetes_url\s.+:(?<metrics_port>\d+)/)['metrics_port'] rescue nil
4
5
  @@live_if = lambda { true }
5
6
  @@ready_if = lambda { true }
7
+ @@metrics_port = ENV['KUBERNETES_HEALTH_METRICS_PORT'] || METRICS_PORT_FROM_PUMA_CONFIG || 9393
6
8
  @@enable_lock_on_migrate = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_LOCK_ON_MIGRATE']
7
9
  @@enable_rack_on_migrate = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_RACK_ON_MIGRATE']
8
10
  @@enable_rack_on_sidekiq = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_RACK_ON_SIDEKIQ']
@@ -113,6 +115,14 @@ module Kubernetes
113
115
  def self.response_format=(value)
114
116
  @@response_format = value
115
117
  end
118
+
119
+ def self.metrics_port
120
+ @@metrics_port
121
+ end
122
+
123
+ def self.metrics_port=(value)
124
+ @@metrics_port = value
125
+ end
116
126
  end
117
127
  end
118
128
  end
@@ -4,7 +4,7 @@ require "kubernetes/health/rack_on_migrate"
4
4
  namespace :kubernetes_health do
5
5
  task :rack_on_migrate do
6
6
  Thread.new do
7
- Rack::Handler.default.run Kubernetes::Health::RackOnMigrate.new
7
+ Rack::Handler::WEBrick.run Kubernetes::Health::RackOnMigrate.new, { Port: Kubernetes::Health::Config.metrics_port }
8
8
  end
9
9
  end
10
10
  end
@@ -11,7 +11,7 @@ module Kubernetes
11
11
  else
12
12
  http_code = 404
13
13
  end
14
- ::Kubernetes::Health::Config.request_log_callback.call(req, http_code)
14
+ ::Kubernetes::Health::Config.request_log_callback.call(req, http_code, '')
15
15
  [http_code, {}, []]
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module Kubernetes
2
2
  module Health
3
- VERSION = '3.10.1'.freeze
3
+ VERSION = '3.11.0'.freeze
4
4
  end
5
5
  end
@@ -54,7 +54,9 @@ module Puma
54
54
  end
55
55
 
56
56
  def generate_extended_puma_stats
57
- puma_stats = @launcher&.stats || {}
57
+ return {} if @launcher.nil?
58
+
59
+ puma_stats = @launcher.stats
58
60
  # On puma <= 4 puma_stats is a String
59
61
  puma_stats = JSON.parse(puma_stats, symbolize_names: true) unless puma_stats.is_a?(Hash)
60
62
  # Including usage stats.
@@ -3,7 +3,7 @@ require 'puma/kubernetes/dsl'
3
3
  Puma::Plugin.create do
4
4
  # rubocop:disable Kubernetes/MethodLength, Kubernetes/AbcSize
5
5
  def start(launcher)
6
- str = launcher.options[:kubernetes_url] || 'tcp://0.0.0.0:9393'
6
+ str = launcher.options[:kubernetes_url] || "tcp://0.0.0.0:#{Kubernetes::Health::Config.metrics_port}"
7
7
 
8
8
  require 'puma/kubernetes/app'
9
9
 
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.10.1
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wagner Caixeta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler