Fixes #XXXXX - Reuse persistent Foreman connections#950
Conversation
|
This would need theforeman/foreman-packaging#13670. |
|
Alternative smaller implementation: #951. |
Keep ForemanRequest as the existing entry point for outbound Foreman calls, but back it with a memoized Net::HTTP::Persistent client instead of creating a new Net::HTTP instance for each request. This keeps the change narrowly focused on connection reuse for proxy-to-Foreman traffic while preserving the current request-building flow used by registration and template callers. The updated tests cover shared-client reuse, SSL compatibility, and the keep-alive headers now emitted by the persistent client. Co-authored-by: Cursor <cursoragent@cursor.com>
204d9c4 to
61c1519
Compare
|
Reduced version of the code. |
|
We deployed PR #950 on 6 capsules under incremental registration load from 76 to 1140 concurrent hosts. Satellite was configured with CLOSE-WAIT accumulation: All capsules accumulated 80-103 CLOSE-WAIT sockets to Satellite:443 with 0 ESTAB, visible even at rest between batches. Satellite closes connections after ConnectionPool::TimeoutError under load: Starting at ~300 concurrent hosts, requests failed with POST /register failures: ~2-3% of POSTs failed with Connection reuse worked correctly under sequential load (20 requests, 1 socket). The issues appeared under concurrent WEBrick load. Why
|
Summary
Net::HTTP::Persistentclient for outboundsmart-proxy -> Foremanrequests instead of creating a freshNet::HTTPclient for each requestForemanRequestas the existing entry point so the request-building flow used by registration and template callers stays unchangedTest plan
bundle3.2 exec ruby3.2 -Itest test/request_test.rbbundle3.2 exec ruby3.2 -Itest test/templates/template_proxy_request_test.rbbundle3.2 exec ruby3.2 -Itest test/registration/registration_api_test.rbbundle3.2 exec rubocop lib/proxy/request.rb test/request_test.rb test/templates/template_proxy_request_test.rb test/registration/registration_api_test.rb smart_proxy.gemspecbundle3.2 exec rake test(rubyipmiis missing in this environment, so the suite stops intest/bmc/...before reaching completion)