Elasticsearch API throwing ValueError in PROD, fine in DEV/QAT

Hi there,

I'm experiencing an issue with the Python packages elasticsearch and elastic_transport in an OCP cluster. The code I'm using works in DEV and QAT environments but throws this error in PROD:

Traceback (most recent call last):
  File "src/update_watchers.py", line 18, in <module>
    es = ElasticResource(config)
  File "/app/src/utils/elastic_resources.py", line 29, in __init__
    config['elastic']['password']))
  File "/usr/local/miniconda/lib/python3.7/site-packages/elasticsearch/_sync/client/__init__.py", line 399, in __init__
    **transport_kwargs,
  File "/usr/local/miniconda/lib/python3.7/site-packages/elastic_transport/_transport.py", line 233, in __init__
    **node_pool_kwargs,
  File "/usr/local/miniconda/lib/python3.7/site-packages/elastic_transport/_node_pool.py", line 180, in __init__
    raise ValueError("Cannot use duplicate NodeConfigs within a NodePool")
ValueError: Cannot use duplicate NodeConfigs within a NodePool

The file src/update_watchers.py is my code where I am trying to instantiate the class on line 18.

Python package versions are:

  • elastic-transport 8.1.2
  • elasticsearch 8.2.3

Has anyone encountered this type of issue before? I'm perplexed as to why it would work in the lower environments but not in PROD when it's the same codebase. Should I consider raising an issue on GitHub?

This is my code where I am trying to instantiate the class:

update_watchers.py

env = resolve_env(os.getenv('KUBERNETES_NAMESPACE'))
 
config = {
  'elastic' : {
    'username' : os.getenv('ELASTIC_USERNAME'),
    'password' : os.getenv('ELASTIC_PASSWORD')
  }
}

es = ElasticResource(config)

elastic_resource.py

class ElasticResource():
    def __init__(self, config):
      self.config = config
 
      self.es = Elasticsearch(
        elastic_url,
        basic_auth=(config['elastic']['username'],
        config['elastic']['password']))

Resolved the issue - the API and server versions did not match.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.