Adapt Puma config to support Puma 7
What does this merge request do and why?
The GDK configuration file needs to be adjusted to work with Puma 7:
-
The callback hooks have been renamed in https://github.com/puma/puma/pull/3438:
-
on_worker_boot->before_worker_boot -
on_worker_shutdown->before_worker_shutdown -
on_restart->before_restart
-
This commit adds a conditional block based on the Puma version to use the new hooks.
- With https://github.com/puma/puma/pull/3297, Puma 7 raises an exception if Puma's options are accessed before they are fully loaded. Currently we pass these options during loading of the Puma config file, which then triggers this exception. These options are used to determine whether Puma is in clustered mode by checking the number of workers.
This commit uses a new method set_puma_worker_count added in
gitlab!204104 (merged).
Note that https://github.com/puma/puma/pull/3731 fixes an upstream
bug to make Puma 7 work with queue_requests set to false.
How to set up and validate locally
- Update
gitlabto Puma 7:
diff --git a/Gemfile b/Gemfile
index bc01f3417337..62f5249dabb5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -287,7 +287,7 @@ gem 'rack', '~> 2.2.9', feature_category: :shared
gem 'rack-timeout', '~> 0.7.0', require: 'rack/timeout/base', feature_category: :shared
group :puma do
- gem 'puma', '= 6.6.1', require: false, feature_category: :shared
+ gem 'puma', '= 7.0.1', require: false, feature_category: :shared
gem 'sd_notify', '~> 0.1.0', require: false, feature_category: :shared
end
diff --git a/Gemfile.lock b/Gemfile.lock
index a0d3e8721446..119e1da4bd6a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1529,7 +1529,7 @@ GEM
date
stringio
public_suffix (6.0.1)
- puma (6.6.1)
+ puma (7.0.1)
nio4r (~> 2.0)
pyu-ruby-sasl (0.0.3.3)
raabro (1.4.0)
@@ -2339,7 +2339,7 @@ DEPENDENCIES
pry-byebug
pry-rails (~> 0.3.9)
pry-shell (~> 0.6.4)
- puma (= 6.6.1)
+ puma (= 7.0.1)
rack (~> 2.2.9)
rack-attack (~> 6.7.0)
rack-cors (~> 2.0.1)
-
Apply the patch in https://github.com/puma/puma/pull/3731.
-
Check out this branch and run
gdk reconfigure. -
gdk restart rails-web
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This MR references an issue describing the change. -
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctortest added, if needed.
Edited by Stan Hu