kubernetes-health 3.10.0 → 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: f3ad95fa7855c4e929a649861a3b8e76c4c5178d4f0a9d15d4f59dbecd412d05
4
- data.tar.gz: 8ddc6657bc1625af9a8397717a5c624363117396aa9f356d686d020753925a29
3
+ metadata.gz: 588adb5d1b5a937a87c4c71f9b98902faee308d64b679df40784bbf66a7a8cc1
4
+ data.tar.gz: ebecbf287f66d584e48b22cbf038dd042cb32bfc7dde3be298c9cc87766ed0fe
5
5
  SHA512:
6
- metadata.gz: 0b50588ad78d95dc0bb29ca932062eaf30ed6fdc5174e6e5a1c158d8c97494315ecde1bc1a67ebf4b53cb769dbabdbf8e8e998a78592a62a41cd108f36ee5f79
7
- data.tar.gz: 707b24d2add09186c55db3899765b3ef560c55d8941785ea6b0a727189305dfe178885839f14ce498da1fa070fff67a38c8f42e925c7f927cb2193483c616815
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.0'.freeze
3
+ VERSION = '3.11.0'.freeze
4
4
  end
5
5
  end
@@ -54,6 +54,8 @@ module Puma
54
54
  end
55
55
 
56
56
  def generate_extended_puma_stats
57
+ return {} if @launcher.nil?
58
+
57
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)
@@ -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.0
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: 2023-10-27 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
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.3.3
172
+ rubygems_version: 3.5.5
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: This gem allows kubernetes monitoring your app while it is running migrates