domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
986 stars 214 forks source link

Cannot connect to Opensearch #315

Closed bigon closed 2 years ago

bigon commented 2 years ago

Hello,

You are using the official python library from elastic to connect, but the problem is that they explicitly check whether it's the official elasticsearch or a fork of it and fails the connection:

Traceback (most recent call last):
  File "/usr/local/bin/parsedmarc", line 8, in <module>
    sys.exit(_main())
  File "/usr/local/lib/python3.9/dist-packages/parsedmarc/cli.py", line 686, in _main
    elastic.migrate_indexes(aggregate_indexes=[es_aggregate_index],
  File "/usr/local/lib/python3.9/dist-packages/parsedmarc/elastic.py", line 244, in migrate_indexes
    if not Index(aggregate_index_name).exists():
  File "/usr/local/lib/python3.9/dist-packages/elasticsearch_dsl/index.py", line 414, in exists
    return self._get_connection(using).indices.exists(index=self._name, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/elasticsearch/client/utils.py", line 347, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/elasticsearch/client/indices.py", line 371, in exists
    return self.transport.perform_request(
  File "/usr/local/lib/python3.9/dist-packages/elasticsearch/transport.py", line 421, in perform_request
    _ProductChecker.raise_error(self._verified_elasticsearch)
  File "/usr/local/lib/python3.9/dist-packages/elasticsearch/transport.py", line 638, in raise_error
    raise UnsupportedProductError(message)
elasticsearch.exceptions.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product

Maybe you should switch to a fork of the connection library that doesn't do such verification instead? https://github.com/opensearch-project/opensearch-py

nathanthorpe commented 2 years ago

In v8 of parsedmarc, the elasticsearch-py library is pinned to <7.14 which doesn't have that check. That release should be on pip in a short while.

I agree though, the opensearch-py library would be good to move to.

seanthegeek commented 2 years ago

Fixed in 8.0.3

seanthegeek commented 2 years ago

Also, I forgot to mention that I can't use the opensearch client module in this project, because they don't have a high-level replacement for elasticsearch-dsl. (yet?)

talyz commented 1 year ago

Looks like there is one now: https://pypi.org/project/opensearch-dsl/