Skip to content

Commit cfe3296

Browse files
ldmingiziang
andauthored
chore: udpate es for kb09 (#1801)
Co-authored-by: Guo Ziang <ziang.gza@apecloud.com>
1 parent 7aa4945 commit cfe3296

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

addons/elasticsearch/dataprotection/backup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export PATH=$PATH:/usr/share/elasticsearch/bin
99
cat /etc/datasafed/datasafed.conf
1010
toolConfig=/etc/datasafed/datasafed.conf
1111
REPOSITORY=kb-backup
12-
ES_ENDPOINT=http://${DP_DB_HOST}:9200
12+
ES_ENDPOINT=http://${DP_DB_HOST}.${KB_NAMESPACE}.svc.cluster.local:9200
1313

1414
# if the script exits with a non-zero exit code, touch a file to indicate that the backup failed,
1515
# the sync progress container will check this file and exit if it exists
@@ -28,7 +28,7 @@ trap handle_exit EXIT
2828

2929
function getToolConfigValue() {
3030
local var=$1
31-
cat $toolConfig | grep "$var" | awk '{print $NF}'
31+
cat $toolConfig | grep "$var[[:space:]]*=" | awk '{print $NF}'
3232
}
3333

3434
s3_endpoint=$(getToolConfigValue endpoint)

addons/elasticsearch/dataprotection/restore.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o errexit
55

66
cat /etc/datasafed/datasafed.conf
77
toolConfig=/etc/datasafed/datasafed.conf
8-
ES_ENDPOINT=http://${DP_DB_HOST}:9200
8+
ES_ENDPOINT=http://${DP_DB_HOST}.${KB_NAMESPACE}.svc.cluster.local:9200
99
REPOSITORY=kb-restore
1010

1111
# if the script exits with a non-zero exit code, touch a file to indicate that the backup failed,
@@ -22,7 +22,7 @@ trap handle_exit EXIT
2222

2323
function getToolConfigValue() {
2424
local var=$1
25-
cat $toolConfig | grep "$var" | awk '{print $NF}'
25+
cat $toolConfig | grep "$var[[:space:]]*=" | awk '{print $NF}'
2626
}
2727

2828
s3_endpoint=$(getToolConfigValue endpoint)
@@ -213,6 +213,20 @@ curl -f -s -X POST "${ES_ENDPOINT}/_snapshot/${REPOSITORY}/${backup_name}/_resto
213213
}
214214
'
215215

216+
# Wait for the cluster health to become green after restore
217+
wait_interval=10 # Check every 10 seconds
218+
219+
while true; do
220+
# Query cluster health status
221+
health_status=$(curl -s "${ES_ENDPOINT}/_cluster/health" | grep -o '"status":"[^\"]*"' | awk -F: '{print $2}' | tr -d '"')
222+
echo "Current cluster health status: $health_status"
223+
if [[ "$health_status" == "green" ]]; then
224+
echo "Cluster health is green, restore is complete."
225+
break
226+
fi
227+
sleep $wait_interval
228+
done
229+
216230
enable_indexing_and_geoip true
217231

218232
switch_ilm start

0 commit comments

Comments
 (0)