Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Empty error 400 when checking for an index #712

Open
Sinan-Karakaya opened this issue Mar 25, 2024 · 4 comments
Open

[BUG] Empty error 400 when checking for an index #712

Sinan-Karakaya opened this issue Mar 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Sinan-Karakaya
Copy link

Sinan-Karakaya commented Mar 25, 2024

Describe the bug

When I try to run any command to interact with my opensearch node, I get an error 400 that has no TransportMessage, making it hard to see what's going on. I should note that this happened after I added an opensearch dashboard container, before, it was running just fine. Here is the stacktrace:

  File "/Users/skarakay/Dev/stan/app/main/opensearch/rag.py", line 54, in check_if_index_exists
    if OS_CLIENT.indices.exists(index=index):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/client/utils.py", line 181, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/client/indices.py", line 428, in exists
    return self.transport.perform_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/transport.py", line 448, in perform_request
    raise e
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/transport.py", line 409, in perform_request
    status, headers_response, data = connection.perform_request(
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/connection/http_urllib3.py", line 290, in perform_request
    self._raise_error(
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/connection/base.py", line 316, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
opensearchpy.exceptions.RequestError: RequestError(400, '')

And here is the code:

OS_CLIENT = OpenSearch(
    hosts=[OPENSEARCH_URL],
    http_auth=(OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD),
    use_ssl=False,
    verify_certs=False,
)

def check_if_index_exists(index: str) -> None:
    try:
        if OS_CLIENT.indices.exists(index=index):
            OS_CLIENT.indices.delete(index=index)
        idx_settings = INDEX_SETTINGS_TEMPLATE.copy()
        idx_settings["mappings"]["properties"] = {
            index: {
                "type": "knn_vector",
                "dimension": 4096,
                "method": {"name": "hnsw", "space_type": "l2", "engine": "faiss"},
            }
        }
        OS_CLIENT.indices.create(index=index, body=idx_settings)
    except Exception as e:
        raise e

I can ping the container just fine:

{
  "name" : "d7019020e897",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "_XG-GxzGSLyjj4l2jkHjmA",
  "version" : {
    "distribution" : "opensearch",
    "number" : "2.12.0",
    "build_type" : "tar",
    "build_hash" : "2c355ce1a427e4a528778d4054436b5c4b756221",
    "build_date" : "2024-02-20T02:18:49.874618333Z",
    "build_snapshot" : false,
    "lucene_version" : "9.9.2",
    "minimum_wire_compatibility_version" : "7.10.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/"
}

There are no logs on the node side. In case, since I suspect this is where it's coming from, here is my containers in my compose:

node-opensearch:
    container_name: node-opensearch
    image: opensearchproject/opensearch:2.12.0
    env_file:
      - path: .env
        required: false
    environment:
      - discovery.type=single-node
      - plugins.security.disabled=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 15821:9200
      - 15822:9600
    networks:
      - opensearch-net

  opensearch-dashboards:
    image: opensearchproject/opensearch-dashboards:2.12.0
    ports:
      - 15823:5601
    expose:
      - "5601"
    environment:
      DISABLE_SECURITY_DASHBOARDS_PLUGIN: true
      OPENSEARCH_HOSTS: '["http://node-opensearch:9200"]'
    networks:
      - opensearch-net

networks:
  opensearch-net:

Related component

Other

To Reproduce

  • Launch the containers just like in the docker compose
  • Try the python code
  • Fail

Expected behavior

I should be able to execute my commands correctly, with or without a dashboard running

Additional Details

Everything is in the description.

@Sinan-Karakaya Sinan-Karakaya added bug Something isn't working untriaged Need triage labels Mar 25, 2024
@Sinan-Karakaya
Copy link
Author

Sinan-Karakaya commented Mar 25, 2024

When running the container without a dashboard running on the side, the stacktrace changes and I get this:

  File "/Users/skarakay/Dev/stan/app/main/opensearch/rag.py", line 54, in check_if_index_exists
    if OS_CLIENT.indices.exists(index=index):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/client/utils.py", line 181, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/client/indices.py", line 428, in exists
    return self.transport.perform_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/transport.py", line 446, in perform_request
    raise e
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/transport.py", line 409, in perform_request
    status, headers_response, data = connection.perform_request(
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skarakay/Dev/stan/.venv/lib/python3.12/site-packages/opensearchpy/connection/http_urllib3.py", line 279, in perform_request
    raise ConnectionError("N/A", str(e), e)
opensearchpy.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x13ec6aea0>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x13ec6aea0>: Failed to establish a new connection: [Errno 61] Connection refused)

This means that surely I did something wrong, but I have no idea what broke everything since it was working fine before

@Sinan-Karakaya
Copy link
Author

Well, I feel dumb.
The failing in connection was due to me not setting properly the environment variables in my Python script.

However, I'm still leaving the issue open, as the empty error message is still not very helpful.

@dblock
Copy link
Member

dblock commented Mar 26, 2024

Is the issue in the actual 400 response or the python client parsing it? Can you reproduce this with curl, what's the server returning?

@peternied
Copy link
Member

[Triage - attendees 1 2 3 4 5 6 7]

@opensearch-project/admin Please transfer this issue to the python client repo

@bbarani bbarani transferred this issue from opensearch-project/OpenSearch Mar 27, 2024
@saimedhi saimedhi removed the untriaged Need triage label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants