From e748488e4a5cdc196e11f2e3071c0ccfa6ce7971 Mon Sep 17 00:00:00 2001 From: Mashhur <99575341+mashhurs@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:03:07 -0700 Subject: [PATCH] Upgrade elasticsearch-ruby client. (#17161) * Upgrade elasticsearch-ruby client. * Fix Faraday removed basic auth option and apply the ES client module name change. --- Gemfile.template | 1 - logstash-core/logstash-core.gemspec | 4 ++-- logstash-core/spec/logstash/webserver_spec.rb | 4 ++-- qa/integration/specs/dlq_spec.rb | 4 ++-- x-pack/qa/integration/management/multiple_pipelines_spec.rb | 2 +- .../monitoring/es_documents_structure_validation_spec.rb | 4 ++-- x-pack/qa/integration/support/helpers.rb | 2 +- x-pack/qa/integration/support/shared_examples.rb | 4 ++-- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Gemfile.template b/Gemfile.template index bc2c7a7d3..e9c1bb9ee 100644 --- a/Gemfile.template +++ b/Gemfile.template @@ -13,7 +13,6 @@ gem "ruby-maven-libs", "~> 3", ">= 3.9.6.1" gem "logstash-output-elasticsearch", ">= 11.14.0" gem "polyglot", require: false gem "treetop", require: false -gem "faraday", "~> 1", :require => false # due elasticsearch-transport (elastic-transport) depending faraday '~> 1' gem "minitar", "~> 1", :group => :build gem "childprocess", "~> 4", :group => :build gem "fpm", "~> 1", ">= 1.14.1", :group => :build # compound due to bugfix https://github.com/jordansissel/fpm/pull/1856 diff --git a/logstash-core/logstash-core.gemspec b/logstash-core/logstash-core.gemspec index bb1a043e1..43b425897 100644 --- a/logstash-core/logstash-core.gemspec +++ b/logstash-core/logstash-core.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |gem| gem.email = ["info@elastic.co"] gem.description = %q{The core components of logstash, the scalable log and event management tool} gem.summary = %q{logstash-core - The core components of logstash} - gem.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html" + gem.homepage = "https://www.elastic.co/logstash" gem.license = "Apache-2.0" gem.files = Dir.glob( @@ -78,7 +78,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency "jrjackson", "= #{ALL_VERSIONS.fetch('jrjackson')}" #(Apache 2.0 license) - gem.add_runtime_dependency "elasticsearch", '~> 7' + gem.add_runtime_dependency "elasticsearch", '~> 8' gem.add_runtime_dependency "manticore", '~> 0.6' # xpack geoip database service diff --git a/logstash-core/spec/logstash/webserver_spec.rb b/logstash-core/spec/logstash/webserver_spec.rb index 048a4563d..e5e2c4e37 100644 --- a/logstash-core/spec/logstash/webserver_spec.rb +++ b/logstash-core/spec/logstash/webserver_spec.rb @@ -191,7 +191,7 @@ describe LogStash::WebServer do context "and invalid basic auth is provided" do it 'emits an HTTP 401 with WWW-Authenticate header' do response = Faraday.new("http://#{api_host}:#{webserver.port}") do |conn| - conn.request :basic_auth, 'john-doe', 'open-sesame' + conn.request :authorization, :basic, 'john-doe', 'open-sesame' end.get('/') aggregate_failures do expect(response.status).to eq(401) @@ -202,7 +202,7 @@ describe LogStash::WebServer do context "and valid auth is provided" do it "returns a relevant response" do response = Faraday.new("http://#{api_host}:#{webserver.port}") do |conn| - conn.request :basic_auth, 'a-user', 's3cur3dPas!' + conn.request :authorization, :basic, 'a-user', 's3cur3dPas!' end.get('/') aggregate_failures do expect(response.status).to eq(200) diff --git a/qa/integration/specs/dlq_spec.rb b/qa/integration/specs/dlq_spec.rb index 965b39d0c..db1879d5f 100644 --- a/qa/integration/specs/dlq_spec.rb +++ b/qa/integration/specs/dlq_spec.rb @@ -83,10 +83,10 @@ describe "Test Dead Letter Queue" do try(60) do begin result = es_client.search(index: 'test-index', size: 0, q: '*') - rescue Elasticsearch::Transport::Transport::Errors::ServiceUnavailable => e + rescue Elastic::Transport::Transport::Errors::ServiceUnavailable => e puts "Elasticsearch unavailable #{e.inspect}" hits = 0 - rescue Elasticsearch::Transport::Transport::Errors::NotFound => e + rescue Elastic::Transport::Transport::Errors::NotFound => e puts "Index not found" hits = 0 end diff --git a/x-pack/qa/integration/management/multiple_pipelines_spec.rb b/x-pack/qa/integration/management/multiple_pipelines_spec.rb index a7b66de6f..612f4cd8e 100644 --- a/x-pack/qa/integration/management/multiple_pipelines_spec.rb +++ b/x-pack/qa/integration/management/multiple_pipelines_spec.rb @@ -138,7 +138,7 @@ describe "Read configuration from elasticsearch" do begin res = elasticsearch_client.search(index: '.monitoring-logstash-*', body: query) - rescue Elasticsearch::Transport::Transport::Errors::ServiceUnavailable + rescue Elastic::Transport::Transport::Errors::ServiceUnavailable return nil end diff --git a/x-pack/qa/integration/monitoring/es_documents_structure_validation_spec.rb b/x-pack/qa/integration/monitoring/es_documents_structure_validation_spec.rb index f47115318..94fb9b7b5 100644 --- a/x-pack/qa/integration/monitoring/es_documents_structure_validation_spec.rb +++ b/x-pack/qa/integration/monitoring/es_documents_structure_validation_spec.rb @@ -19,8 +19,8 @@ describe "Monitoring internal collector documents" do let(:retryable_errors) do [NoMethodError, RSpec::Expectations::ExpectationNotMetError, - Elasticsearch::Transport::Transport::Errors::ServiceUnavailable, - Elasticsearch::Transport::Transport::Errors::NotFound] + Elastic::Transport::Transport::Errors::ServiceUnavailable, + Elastic::Transport::Transport::Errors::NotFound] end describe "metrics" do diff --git a/x-pack/qa/integration/support/helpers.rb b/x-pack/qa/integration/support/helpers.rb index a216d1cd8..0122b8dba 100644 --- a/x-pack/qa/integration/support/helpers.rb +++ b/x-pack/qa/integration/support/helpers.rb @@ -124,7 +124,7 @@ def cleanup_system_indices(pipeline_ids) pipeline_ids.each do |id| begin elasticsearch_client.perform_request(:delete, "_logstash/pipeline/#{id}") - rescue Elasticsearch::Transport::Transport::Errors::NotFound => e + rescue Elastic::Transport::Transport::Errors::NotFound => e puts ".logstash can be empty #{e.message}" end end diff --git a/x-pack/qa/integration/support/shared_examples.rb b/x-pack/qa/integration/support/shared_examples.rb index 5c8a54f00..e38903396 100644 --- a/x-pack/qa/integration/support/shared_examples.rb +++ b/x-pack/qa/integration/support/shared_examples.rb @@ -9,8 +9,8 @@ shared_examples "record monitoring data to es" do let(:retryable_errors) do [NoMethodError, RSpec::Expectations::ExpectationNotMetError, - Elasticsearch::Transport::Transport::Errors::ServiceUnavailable, - Elasticsearch::Transport::Transport::Errors::NotFound] + Elastic::Transport::Transport::Errors::ServiceUnavailable, + Elastic::Transport::Transport::Errors::NotFound] end describe "metrics" do