Skip to content

Commit

Permalink
fix curator config to support es 8 (#1970)
Browse files Browse the repository at this point in the history
* fix curator config to support es 8

* add customizable protocol flag

* add test cases for curator

* backward compactibility to curator 7.x
  • Loading branch information
pgvishnuram committed Sep 5, 2023
1 parent 8a03bd1 commit cdef554
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
19 changes: 19 additions & 0 deletions charts/elasticsearch/templates/curator/es-curator-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ data:
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
{{ if semverCompare "<8" .Values.images.curator.tag -}}
client:
hosts:
- {{ template "elasticsearch.fullname" . }}
Expand All @@ -63,4 +64,22 @@ data:
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']
{{- else -}}
elasticsearch:
client:
hosts:
- {{ .Values.common.protocol }}://{{ template "elasticsearch.fullname" . }}:{{ .Values.common.ports.http }}
ca_certs:
client_cert:
client_key:
verify_certs:
request_timeout: 30
other_settings:
master_only: False
logging:
loglevel: INFO
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ images:
common:
podAnnotations: {}
serviceType: ClusterIP
protocol: http

env:
CLUSTER_NAME: "astronomer"
Expand Down
72 changes: 71 additions & 1 deletion tests/chart_tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest

import yaml
from tests import get_containers_by_name, supported_k8s_versions
from tests.chart_tests.helm_template_generator import render_chart

Expand Down Expand Up @@ -354,3 +354,73 @@ def test_elasticsearch_role_overrides(self, kube_version):
node_client_roles_env
in docs[2]["spec"]["template"]["spec"]["containers"][0]["env"]
)

def test_elasticsearch_curator_indexPatterns_override_with_loggingSidecar(
self, kube_version
):
"""Test ElasticSearch Curator IndexPattern Override with loggingSidecar"""
indexPattern = "%Y.%m"
docs = render_chart(
kube_version=kube_version,
values={
"global": {
"loggingSidecar": {"enabled": True, "indexPattern": indexPattern}
}
},
show_only=[
"charts/elasticsearch/templates/curator/es-curator-configmap.yaml"
],
)
assert len(docs) == 1
assert (LS := yaml.safe_load(docs[0]["data"]["action_file.yml"]))
assert indexPattern == LS["actions"][1]["filters"][0]["timestring"]

def test_elasticsearch_curator_with_indexPatterns_defaults(self, kube_version):
"""Test ElasticSearch Curator IndexPattern with defaults"""
indexPattern = "%Y.%m.%d"
docs = render_chart(
kube_version=kube_version,
values={},
show_only=[
"charts/elasticsearch/templates/curator/es-curator-configmap.yaml"
],
)
assert len(docs) == 1
assert (LS := yaml.safe_load(docs[0]["data"]["action_file.yml"]))
assert indexPattern == LS["actions"][1]["filters"][0]["timestring"]

def test_elasticsearch_curator_config_defaults(self, kube_version):
"""Test ElasticSearch Curator IndexPattern with defaults"""
docs = render_chart(
kube_version=kube_version,
values={},
show_only=[
"charts/elasticsearch/templates/curator/es-curator-configmap.yaml"
],
)
assert len(docs) == 1
assert (LS := yaml.safe_load(docs[0]["data"]["config.yml"]))
print(LS["elasticsearch"])
assert "elasticsearch" in LS
assert (
"http://release-name-elasticsearch:9200"
in LS["elasticsearch"]["client"]["hosts"]
)

def test_elasticsearch_curator_config_overrides(self, kube_version):
"""Test ElasticSearch Curator IndexPattern with defaults"""
docs = render_chart(
kube_version=kube_version,
values={"elasticsearch": {"common": {"protocol": "https"}}},
show_only=[
"charts/elasticsearch/templates/curator/es-curator-configmap.yaml"
],
)
assert len(docs) == 1
assert (LS := yaml.safe_load(docs[0]["data"]["config.yml"]))
print(LS["elasticsearch"])
assert "elasticsearch" in LS
assert (
"https://release-name-elasticsearch:9200"
in LS["elasticsearch"]["client"]["hosts"]
)

0 comments on commit cdef554

Please sign in to comment.