Skip to content

Commit 2d30260

Browse files
build(deps): bump puma from 6.6.1 to 7.0.4 (#4576)
* deps: bump puma from 6.6.1 to 7.0.4 Bumps [puma](https://github.com/puma/puma) from 6.6.1 to 7.0.4. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](puma/puma@v6.6.1...v7.0.4) --- updated-dependencies: - dependency-name: puma dependency-version: 7.0.4 dependency-type: direct:production update-type: version-update:semver-major * fix platform ref * use Puma 6 defaults --------- Co-authored-by: johha <johannes.haass@sap.com>
1 parent f24452b commit 2d30260

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ GEM
387387
date
388388
stringio
389389
public_suffix (6.0.2)
390-
puma (6.6.1)
390+
puma (7.0.4)
391391
nio4r (~> 2.0)
392392
racc (1.8.1)
393393
rack (2.2.18)

lib/cloud_controller/runners/puma_runner.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def initialize(config, app, logger, periodic_updater, request_logs)
2020
conf.bind "tcp://0.0.0.0:#{config.get(:external_port)}"
2121
end
2222

23+
# Keep Puma 6 defaults (25/20s) to avoid surprises with Nginx. Puma 7 defaults may be revisited for performance later.
24+
conf.max_keep_alive(25)
25+
conf.persistent_timeout(20)
26+
2327
conf.workers(config.get(:puma, :workers) || 1) unless config.get(:puma, :automatic_worker_count)
2428
num_threads = config.get(:puma, :max_threads) || 1
2529
conf.threads(num_threads, num_threads)
@@ -33,32 +37,33 @@ def initialize(config, app, logger, periodic_updater, request_logs)
3337
# Reduce the thread shutdown timeout to 10 seconds (4 [force_shutdown_after] + 5 [SHUTDOWN_GRACE_TIME] + 1)
3438
conf.force_shutdown_after(4)
3539

40+
# replace PidFormatter as we already have the pid in the Steno log record
41+
formatter = Puma::LogWriter::DefaultFormatter.new
42+
conf.log_formatter { |str| formatter.call(str) }
43+
3644
conf.app app
3745
conf.before_fork do
3846
Sequel::Model.db.disconnect
3947
end
40-
conf.on_worker_boot do
48+
conf.before_worker_boot do
4149
ENV['PROCESS_TYPE'] = 'puma_worker'
4250
prometheus_updater.update_gauge_metric(:cc_db_connection_pool_timeouts_total, 0, labels: { process_type: 'puma_worker' })
4351
end
44-
conf.on_worker_shutdown do
52+
conf.before_worker_shutdown do
4553
request_logs.log_incomplete_requests if request_logs
4654
end
4755
end
4856

4957
log_writer = Puma::LogWriter.new(StenoIO.new(logger, :info), StenoIO.new(logger, :error))
5058

51-
# replace PidFormatter as we already have the pid in the Steno log record
52-
puma_config.options[:log_formatter] = Puma::LogWriter::DefaultFormatter.new
53-
5459
events = Puma::Events.new
55-
events.on_booted do
60+
events.after_booted do
5661
prometheus_updater.update_gauge_metric(:cc_db_connection_pool_timeouts_total, 0, labels: { process_type: 'main' })
5762
Thread.new do
5863
EM.run { periodic_updater.setup_updates }
5964
end
6065
end
61-
events.on_stopped do
66+
events.after_stopped do
6267
EM.stop
6368
end
6469

spec/unit/lib/cloud_controller/runners/puma_runner_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,27 @@ module VCAP::CloudController
153153
subject
154154

155155
expect(Sequel::Model.db).to receive(:disconnect)
156-
puma_launcher.config.final_options[:before_fork].first.call
156+
puma_launcher.config.final_options[:before_fork].first[:block].call
157157
end
158158

159-
it 'logs incomplete requests on worker shutdown' do
159+
it 'logs incomplete requests before worker shutdown' do
160160
subject
161161

162162
expect(request_logs).to receive(:log_incomplete_requests)
163-
puma_launcher.config.final_options[:before_worker_shutdown].first.call
163+
puma_launcher.config.final_options[:before_worker_shutdown].first[:block].call
164164
end
165165

166-
it 'initializes the cc_db_connection_pool_timeouts_total for the worker on worker boot' do
166+
it 'initializes the cc_db_connection_pool_timeouts_total for the worker before worker boot' do
167167
subject
168168

169169
expect(prometheus_updater).to receive(:update_gauge_metric).with(:cc_db_connection_pool_timeouts_total, 0, labels: { process_type: 'puma_worker' })
170-
puma_launcher.config.final_options[:before_worker_boot].first.call
170+
puma_launcher.config.final_options[:before_worker_boot].first[:block].call
171171
end
172172

173173
it 'sets environment variable `PROCESS_TYPE` to `puma_worker`' do
174174
subject
175175

176-
puma_launcher.config.final_options[:before_worker_boot].first.call
176+
puma_launcher.config.final_options[:before_worker_boot].first[:block].call
177177
expect(ENV.fetch('PROCESS_TYPE')).to eq('puma_worker')
178178
end
179179
end
@@ -194,22 +194,22 @@ module VCAP::CloudController
194194
end
195195

196196
describe 'Events' do
197-
describe 'on_booted' do
197+
describe 'after_booted' do
198198
it 'sets up periodic metrics updater with EM and initializes cc_db_connection_pool_timeouts_total for the main process' do
199199
expect(Thread).to receive(:new).and_yield
200200
expect(EM).to receive(:run).and_yield
201201
expect(periodic_updater).to receive(:setup_updates)
202202
expect(prometheus_updater).to receive(:update_gauge_metric).with(:cc_db_connection_pool_timeouts_total, 0, labels: { process_type: 'main' })
203203

204-
puma_launcher.events.fire(:on_booted)
204+
puma_launcher.events.fire(:after_booted)
205205
end
206206
end
207207

208-
describe 'on_stopped' do
208+
describe 'after_stopped' do
209209
it 'stops EM and logs incomplete requests' do
210210
expect(EM).to receive(:stop)
211211

212-
puma_launcher.events.fire(:on_stopped)
212+
puma_launcher.events.fire(:after_stopped)
213213
end
214214
end
215215
end

0 commit comments

Comments
 (0)