elasticsearch fix

This commit is contained in:
Leo Sok 2025-06-06 15:48:17 +03:00
parent c7abc80c66
commit d95637041e

View File

@ -578,10 +578,9 @@ postStart:
- -c - -c
- | - |
set -euo pipefail set -euo pipefail
ES_ENCODED_PASSWORD=$(printf "%s" "$ES_PASSWORD" | sed 's/%/%25/g')
echo "[postStart] Waiting for Elasticsearch to be ready..." >&2 echo "[postStart] Waiting for Elasticsearch to be ready..." >&2
for ((i=1; i<=MAX_RETRIES; i++)); do for ((i=1; i<=MAX_RETRIES; i++)); do
if /usr/bin/curl --cacert "$CA_CERT" -s -u "$ES_USERNAME:$ES_ENCODED_PASSWORD" "$ES_URL" >/dev/null; then if /usr/bin/curl --cacert "$CA_CERT" -s -u "$ES_USERNAME:$ELASTIC_PASSWORD" "$ES_URL" >/dev/null; then
echo "[postStart] Elasticsearch is up after $i attempts!" >&2 echo "[postStart] Elasticsearch is up after $i attempts!" >&2
break break
fi fi
@ -593,21 +592,21 @@ postStart:
done done
echo "[postStart] Loading index template from $TEMPLATE_PATH" >&2 echo "[postStart] Loading index template from $TEMPLATE_PATH" >&2
if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/chat_v1_idx" \ if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/chat_v1_idx" \
-u "$ES_USERNAME:$ES_ENCODED_PASSWORD" \ -u "$ES_USERNAME:$ES_PASSWORD" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
--data-binary @"$TEMPLATE_PATH_1"; then --data-binary @"$TEMPLATE_PATH_1"; then
echo "[postStart] ERROR: Failed to apply index template!" >&2 echo "[postStart] ERROR: Failed to apply index template!" >&2
exit 1 exit 1
fi fi
if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/message_v1_idx" \ if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/message_v1_idx" \
-u "$ES_USERNAME:$ES_ENCODED_PASSWORD" \ -u "$ES_USERNAME:$ELASTIC_PASSWORD" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
--data-binary @"$TEMPLATE_PATH_2"; then --data-binary @"$TEMPLATE_PATH_2"; then
echo "[postStart] ERROR: Failed to apply index template!" >&2 echo "[postStart] ERROR: Failed to apply index template!" >&2
exit 1 exit 1
fi fi
if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/user_v1_idx" \ if ! /usr/bin/curl --cacert "$CA_CERT" -X PUT "$ES_URL/user_v1_idx" \
-u "$ES_USERNAME:$ES_ENCODED_PASSWORD" \ -u "$ES_USERNAME:$ELASTIC_PASSWORD" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
--data-binary @"$TEMPLATE_PATH_3"; then --data-binary @"$TEMPLATE_PATH_3"; then
echo "[postStart] ERROR: Failed to apply index template!" >&2 echo "[postStart] ERROR: Failed to apply index template!" >&2