Skip to content

Commit 7dca94f

Browse files
committed
chore: tidy up
1 parent 2e8087a commit 7dca94f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

addons/elasticsearch/configs/elasticsearch-8.yml.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ cluster:
1515
awareness:
1616
{{- if eq $zoneAwareEnabled "true" }}
1717
attributes: zone,k8s_node_name
18+
force:
19+
zone:
20+
values: ${ALL_ZONES}
1821
{{- else }}
1922
attributes: k8s_node_name
2023
{{- end }}
@@ -68,7 +71,7 @@ node:
6871
attr:
6972
k8s_node_name: ${NODE_NAME}
7073
{{- if eq $zoneAwareEnabled "true" }}
71-
zone: ${ZONE_NAME}
74+
zone: ${CURRENT_ZONE}
7275
{{- end }}
7376
name: ${POD_NAME}
7477
store:

addons/elasticsearch/scripts/entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ if [ "${ZONE_AWARE_ENABLED}" = "true" ]; then
1010
echo "Error: ZONE_AWARE_ENABLED is true but NODE_NAME is not set"
1111
exit 1
1212
fi
13-
ZONE_NAME=""
13+
CURRENT_ZONE=""
14+
ZONES=()
1415
IFS=';' read -ra PARTS <<< "${ZONE_AWARE_MAPPING}"
1516
for PART in "${PARTS[@]}"; do
1617
IFS=':' read -ra ZONE_PART <<< "${PART}"
@@ -21,20 +22,24 @@ if [ "${ZONE_AWARE_ENABLED}" = "true" ]; then
2122
for NODE in "${NODE_LIST[@]}"; do
2223
NODE_NAME_TRIMMED="${NODE// /}"
2324
if [ "${NODE_NAME_TRIMMED}" = "${NODE_NAME}" ]; then
24-
export ZONE_NAME="${ZONE}"
25+
export CURRENT_ZONE="${ZONE}"
26+
ZONES+=("${ZONE}")
2527
break
2628
fi
2729
done
28-
if [ -n "${ZONE_NAME}" ]; then
30+
if [ -n "${CURRENT_ZONE}" ]; then
2931
break
3032
fi
3133
fi
3234
done
33-
if [ -z "${ZONE_NAME}" ]; then
35+
if [ -z "${CURRENT_ZONE}" ]; then
3436
echo "Error: ZONE_AWARE_ENABLED is true but failed to find zone for node ${NODE_NAME} in ZONE_AWARE_MAPPING: ${ZONE_AWARE_MAPPING}"
3537
exit 1
3638
fi
3739
fi
40+
# join ZONES array with comma
41+
ALL_ZONES=$(IFS=,; echo "${ZONES[*]}")
42+
export ALL_ZONES
3843
# remove initial master nodes block if cluster has been formed
3944
if [ -f "${CLUSTER_FORMED_FILE}" ]; then
4045
sed -i '/# INITIAL_MASTER_NODES_BLOCK_START/,/# INITIAL_MASTER_NODES_BLOCK_END/d' config/elasticsearch.yml

0 commit comments

Comments
 (0)