Skip to content

Commit

Permalink
fix: opensearch configuration should consume the ca_certs parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Jan 15, 2025
1 parent 2778630 commit 8effd9b
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/DIRAC/ConfigurationSystem/Client/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,19 @@ def getElasticDBParameters(fullname):
:return: S_OK(dict)/S_ERROR()
"""

def _getCACerts(cs_path):
result = gConfig.getOption(cs_path + "/ca_certs")
if not result["OK"]:
# No CA certificate found, try at the common place
result = gConfig.getOption("/Systems/NoSQLDatabases/ca_certs")
if not result["OK"]:
return None
else:
ca_certs = result["Value"]
else:
ca_certs = result["Value"]
return ca_certs

cs_path = getDatabaseSection(fullname)
parameters = {}

Expand All @@ -469,17 +482,9 @@ def getElasticDBParameters(fullname):
parameters["Password"] = None
parameters["User"] = None

# Elasticsearch ca_certs
result = gConfig.getOption(cs_path + "/ca_certs")
if not result["OK"]:
# No CA certificate found, try at the common place
result = gConfig.getOption("/Systems/NoSQLDatabases/ca_certs")
if not result["OK"]:
return S_ERROR("Failed to get the configuration parameter: ca_certs.")
else:
ca_certs = result["Value"]
else:
ca_certs = result["Value"]
ca_certs = _getCACerts(cs_path)
if ca_certs is None:
return S_ERROR("Failed to get the configuration parameter: ca_certs.")
parameters["ca_certs"] = ca_certs

# Elasticsearch client_key
Expand Down Expand Up @@ -527,6 +532,11 @@ def getElasticDBParameters(fullname):
dbUser = result["Value"]
parameters["User"] = dbUser

# ca_certs is not mandatory
ca_certs = _getCACerts(cs_path)
if ca_certs:
parameters["ca_certs"] = ca_certs

# Check optional parameters: Host, Port, SSL
result = gConfig.getOption(cs_path + "/Host")
if not result["OK"]:
Expand Down

0 comments on commit 8effd9b

Please sign in to comment.