Skip to content

Commit

Permalink
Merge pull request DIRACGrid#7997 from fstagni/cherry-pick-2-f64ea8be…
Browse files Browse the repository at this point in the history
…3-integration

[sweep:integration] fix: opensearch configuration should consume the ca_certs parameter
  • Loading branch information
fstagni authored Jan 17, 2025
2 parents d89cc44 + fb2a193 commit bfe4a83
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 @@ -441,6 +441,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 @@ -464,17 +477,9 @@ def getElasticDBParameters(fullname):
parameters["Password"] = None
parameters["User"] = None

# OpenSearch 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

# OpenSearch client_key
Expand Down Expand Up @@ -522,6 +527,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 bfe4a83

Please sign in to comment.