Resolve "TCP connections from GitLab processes accumulate and do not close after upgrade to 17.11"
What does this MR do and why?
This MR introduces a way for admins to change the Faraday adapter used by Elasticsearch or OpenSearch for the advanced search feature. This also makes changes for AI Active Context, because that feature is able to share the elasticsearch configuration, so the same adapter should be used.
The MR also updates the Gemfile requirements for Ai::Active::Context, will leave notes on those changes with more details
Note: This change is intentionally not available in the Admin UI, it is a very niche setting and should not have to be changed by admins often. If needed, it can be changed via the rails console.
AI Summary
This change adds a new configuration option called elasticsearch_client_adapter
that allows users to choose which network adapter Elasticsearch uses to communicate with the server. Previously, the system was hardcoded to use "typhoeus" as the adapter, but now users can select from 2 different options: typhoeus & net_http. The default remains "typhoeus" to maintain backward compatibility.
The change updates the documentation to describe this new setting, adds it to the application settings interface, includes proper validation to ensure only valid adapter names are accepted, and updates the underlying code to use the selected adapter instead of the hardcoded one. It also adds logging to display which adapter is currently being used and includes comprehensive tests to verify the functionality works correctly.
This enhancement gives administrators more flexibility in how their Elasticsearch connections are handled, which can be useful for different network environments or performance requirements. The change affects both Elasticsearch and OpenSearch implementations and is only available in Premium and Ultimate editions.
References
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
-
setup gdk for elasticsearch
-
check the adapter being used
es_helper = Gitlab::Elastic::Helper.default es_helper.client.transport.transport.options[:adapter] # should be typhoeus
-
change the application setting from console
ApplicationSetting.update!(elasticsearch_client_adapter: 'net_http')
-
ensure the adapter changes
es_helper = Gitlab::Elastic::Helper.default es_helper.client.transport.transport.options[:adapter] # should be net_http
NOTE: make sure you set it back so you aren't stuck with net_http
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.