Итак, у меня есть приложение на Rails 4, в котором я пытаюсь настроить эластичный поиск с использованием gem searchkick. У меня сервер эластичного поиска, работающий на внешнем устройстве, поэтому я устанавливаю соединение в простом инициализаторе:
Searchkick.client = Elasticsearch::Client.new( url: 'http://dajspisac-test:password@estest1.l.besty2.pl' ) if Rails.env.staging?
После развертывания и развертывания при попытке переиндексации модели появляется ошибка:
16: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
15: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
14: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
13: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
12: from (irb):1
11: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/model.rb:59:in `searchkick_reindex'
10: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/index.rb:200:in `reindex'
9: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/index.rb:270:in `reindex_scope'
8: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/index.rb:119:in `clean_indices'
7: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/index.rb:106:in `all_indices'
6: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-api-7.5.0/lib/elasticsearch/api/actions/indices/get_alias.rb:43:in `get_alias'
5: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-api-7.5.0/lib/elasticsearch/api/namespace/common.rb:25:in `perform_request'
4: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/client.rb:152:in `perform_request'
3: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/http/faraday.rb:24:in `perform_request'
2: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:333:in `perform_request'
1: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:205:in `__raise_transport_error'
Elasticsearch::Transport::Transport::Errors::Forbidden ([403] {"error":{"root_cause":[{"type":"security_exception","reason":"no permissions for [indices:admin/aliases/get] and User [name=dajspisac-test, backend_roles=[], requestedTenant=null]"}],"type":"security_exception","reason":"no permissions for [indices:admin/aliases/get] and User [name=dajspisac-test, backend_roles=[], requestedTenant=null]"},"status":403})
, а также при попытке поиска:
16: from (irb):1
15: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/model.rb:43:in `searchkick_search'
14: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick.rb:95:in `search'
13: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick.rb:95:in `new'
12: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/query.rb:43:in `initialize'
11: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/query.rb:298:in `prepare'
10: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/query.rb:298:in `each'
9: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/query.rb:355:in `block in prepare'
8: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick/query.rb:1033:in `below61?'
7: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick.rb:78:in `server_below?'
6: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/searchkick-3.1.3/lib/searchkick.rb:74:in `server_version'
5: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-api-7.5.0/lib/elasticsearch/api/actions/info.rb:22:in `info'
4: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/client.rb:152:in `perform_request'
3: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/http/faraday.rb:24:in `perform_request'
2: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:333:in `perform_request'
1: from /home/dajspisac/dajspisac/shared/vendor/bundle/ruby/2.5.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:205:in `__raise_transport_error'
Elasticsearch::Transport::Transport::Errors::Forbidden ([403] {"error":{"root_cause":[{"type":"security_exception","reason":"no permissions for [cluster:monitor/main] and User [name=dajspisac-test, backend_roles=[], requestedTenant=null]"}],"type":"security_exception","reason":"no permissions for [cluster:monitor/main] and User [name=dajspisac-test, backend_roles=[], requestedTenant=null]"},"status":403})
Да, 403 говорит само за себя, но когда я делаю простой тестовый запрос с того же сервера, с теми же учетными данными к тому же индексу я получаю то, что я просил:
dajspisac@dajspisac-test:~$ http --auth dajspisac-test:password --pretty all GET http://estest1.l.besty2.pl:9200/dajspisac.test1
HTTP/1.1 200 OK
content-encoding: gzip
content-length: 258
content-type: application/json; charset=UTF-8
{
"dajspisac.test1": {
"aliases": {},
"mappings": {
"properties": {
"name": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"settings": {
"index": {
"creation_date": "1587330576604",
"number_of_replicas": "1",
"number_of_shards": "1",
"provided_name": "dajspisac.test1",
"uuid": "DDazlfIXSxakFJeu3rjD9A",
"version": {
"created": "7040299",
"upgraded": "7060199"
}
}
}
}
}
, а также для PUT:
dajspisac@dajspisac-test:~$ http --auth dajspisac-test:password --pretty all PUT http://estest1.l.besty2.pl:9200/dajspisac.test1/_doc/1 name=janekg
HTTP/1.1 200 OK
content-encoding: gzip
content-length: 144
content-type: application/json; charset=UTF-8
{
"_id": "1",
"_index": "dajspisac.test1",
"_primary_term": 4,
"_seq_no": 1,
"_shards": {
"failed": 0,
"successful": 2,
"total": 2
},
"_type": "_doc",
"_version": 2,
"result": "updated"
}
что я делаю неправильно или что я неправильно настроил?
РЕДАКТИРОВАТЬ
конечно, это не ошибка аутентификации, потому что установка неправильного пользователя / пароля дает 401