- Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Elasticsearch version (bin/elasticsearch --version
):
Version: 8.2.2, Build: default/docker/9876968ef3c745186b94fdabd4483e01499224ef/2022-05-25T15:47:06.259735307Z, JVM: 18.0.1.1
elasticsearch-py
version (elasticsearch.__versionstr__
):
8.2.3
Sniffing callback uses Transport instance directly to perform /_nodes/_all/http
requests.
meta, node_infos = await transport.perform_request( |
However, both Authorization and opaque-id headers are NOT passed to Transport class during initialization.
node_configs = client_node_configs( |
Instead they are saved to Elasticsearch client instance after Transport is already created
if headers is not DEFAULT and headers is not None: |
and used for API requests only.
if headers is not DEFAULT and headers is not None: |
As the result sniffing fails with Exception elastic_transport.SniffingError: No viable nodes were discovered on the initial sniff attempt
while the real problem is
{ "error":{ "root_cause":[ { "type":"security_exception", "reason":"missing authentication credentials for REST request [/_nodes/_all/http]", "header":{ "WWW-Authenticate":[ "Basic realm=\"security\" charset=\"UTF-8\"", "ApiKey" ] } } ], "type":"security_exception", "reason":"missing authentication credentials for REST request [/_nodes/_all/http]", "header":{ "WWW-Authenticate":[ "Basic realm=\"security\" charset=\"UTF-8\"", "ApiKey" ] } }, "status":401 }
The problem is the same for both Sync and Async clients.
The fix might be to build opaque-id and authorization headers before transport intialization to and pass them to client_node_configs
method (headers
argument). However, I am not sure if it will work "as intended" with .options()
feature and internal _transport
constructor argument of Elasticsearch
and AsyncElasticsearch
classes.