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

[8.0] fix: opensearch configuration should consume the ca_certs parameter #7992

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading