From b5b84fad65f927a1bf55538be4a4763199724a6e Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 14 May 2024 19:54:28 +0200 Subject: [PATCH] Fix OpenSearch compatibility issue (#30278) --- .github/workflows/test-ruby.yml | 20 ++++++++++++++++++-- config/application.rb | 1 + lib/elasticsearch/client_extensions.rb | 11 +++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lib/elasticsearch/client_extensions.rb diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index 45dc8a0deb..2bfa59e6b1 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -264,8 +264,8 @@ jobs: ports: - 6379:6379 - search: - image: ${{ matrix.search-image }} + elasticsearch: + image: ${{ contains(matrix.search-image, 'elasticsearch') && matrix.search-image || '' }} env: discovery.type: single-node xpack.security.enabled: false @@ -277,6 +277,20 @@ jobs: ports: - 9200:9200 + opensearch: + image: ${{ contains(matrix.search-image, 'opensearch') && matrix.search-image || '' }} + env: + discovery.type: single-node + DISABLE_INSTALL_DEMO_CONFIG: true + DISABLE_SECURITY_PLUGIN: true + options: >- + --health-cmd "curl http://localhost:9200/_cluster/health" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + ports: + - 9200:9200 + env: DB_HOST: localhost DB_USER: postgres @@ -300,6 +314,8 @@ jobs: include: - ruby-version: '.ruby-version' search-image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2 + - ruby-version: '.ruby-version' + search-image: opensearchproject/opensearch:2 steps: - uses: actions/checkout@v4 diff --git a/config/application.rb b/config/application.rb index 402c7f0614..07b50ca036 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,6 +40,7 @@ require_relative '../lib/mastodon/rack_middleware' require_relative '../lib/public_file_server_middleware' require_relative '../lib/devise/strategies/two_factor_ldap_authenticatable' require_relative '../lib/devise/strategies/two_factor_pam_authenticatable' +require_relative '../lib/elasticsearch/client_extensions' require_relative '../lib/chewy/settings_extensions' require_relative '../lib/chewy/index_extensions' require_relative '../lib/chewy/strategy/mastodon' diff --git a/lib/elasticsearch/client_extensions.rb b/lib/elasticsearch/client_extensions.rb new file mode 100644 index 0000000000..700bfa4a1c --- /dev/null +++ b/lib/elasticsearch/client_extensions.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Elasticsearch + module ClientExtensions + def verify_elasticsearch + @verified = true + end + end +end + +Elasticsearch::Client.prepend(Elasticsearch::ClientExtensions)