Skip to content

Commit 00c7db1

Browse files
committed
Update script for Watson Discovery 4.8.5 on CP4D
1 parent 286743f commit 00c7db1

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

discovery-data/latest/all-backup-restore.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SPLIT_DIR=./tmp_split_backup
88
EXTRA_OC_ARGS="${EXTRA_OC_ARGS:-}"
99

1010
SCRIPT_DIR=$(dirname $0)
11+
KUBECONFIG_FILE="${SCRIPT_DIR}/.kubeconfig"
1112

1213
. ${SCRIPT_DIR}/lib/function.bash
1314

@@ -504,6 +505,8 @@ fi
504505
brlog "INFO" "Clean up"
505506

506507
delete_service_account "${BACKUP_RESTORE_SA}"
508+
rm -f "${KUBECONFIG_FILE}"
509+
unset KUBECONFIG
507510
rm -rf "${BACKUP_DIR}"
508511

509512
disable_trap

discovery-data/latest/elastic-backup-restore.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ printUsage() {
3232
exit 1
3333
}
3434

35+
get_recovery_status(){
36+
fetch_cmd_result ${ELASTIC_POD} 'rm -f /tmp/recovery_status.json && export ELASTIC_ENDPOINT=https://localhost:9200 && curl -s -k -u ${ELASTIC_USER}:${ELASTIC_PASSWORD} "${ELASTIC_ENDPOINT}/_recovery" > /tmp/recovery_status.json && cat /tmp/recovery_status.json' ${OC_ARGS} -c elasticsearch
37+
}
38+
3539
if [ $# -lt 2 ] ; then
3640
printUsage
3741
fi
@@ -417,7 +421,7 @@ EOF
417421
total_shards=0
418422
while true;
419423
do
420-
recovery_status=$(fetch_cmd_result ${ELASTIC_POD} 'rm -f /tmp/recovery_status.json && export ELASTIC_ENDPOINT=https://localhost:9200 && curl -s -k -u ${ELASTIC_USER}:${ELASTIC_PASSWORD} "${ELASTIC_ENDPOINT}/_recovery" > /tmp/recovery_status.json && cat /tmp/recovery_status.json' ${OC_ARGS} -c elasticsearch)
424+
recovery_status=$(get_recovery_status)
421425
brlog "DEBUG" "Recovery Status: ${recovery_status}"
422426
if [ "${recovery_status}" != "{}" ] ; then
423427
tmp_total_shards=$(fetch_cmd_result ${ELASTIC_POD} 'cat /tmp/recovery_status.json | jq ".[].shards[]" | jq -s ". | length"' ${OC_ARGS} -c elasticsearch)
@@ -441,7 +445,9 @@ EOF
441445
brlog "INFO" "Total shards in snapshot: ${total_shards}"
442446
while true;
443447
do
444-
done_count=$(fetch_cmd_result ${ELASTIC_POD} 'export ELASTIC_ENDPOINT=https://localhost:9200 && curl -s -k -u ${ELASTIC_USER}:${ELASTIC_PASSWORD} "${ELASTIC_ENDPOINT}/_recovery" | jq '"'"'.[].shards[] | select(.stage == "DONE")'"'"' | jq -s ". | length"' ${OC_ARGS} -c elasticsearch)
448+
recovery_status=$(get_recovery_status)
449+
total_shards=$(fetch_cmd_result ${ELASTIC_POD} 'cat /tmp/recovery_status.json | jq ".[].shards[]" | jq -s ". | length"' ${OC_ARGS} -c elasticsearch)
450+
done_count=$(fetch_cmd_result ${ELASTIC_POD} 'cat /tmp/recovery_status.json | jq '"'"'.[].shards[] | select(.stage == "DONE")'"'"' | jq -s ". | length"' ${OC_ARGS} -c elasticsearch)
445451
brlog "INFO" "${done_count} shards finished"
446452
if [ ${done_count} -ge ${total_shards} ] ; then
447453
break

discovery-data/latest/lib/function.bash

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,8 +1460,10 @@ delete_service_account(){
14601460
oc_login_as_scripts_user(){
14611461
create_service_account "${BACKUP_RESTORE_SA}"
14621462
local oc_token=$(get_oc_token "${BACKUP_RESTORE_SA}")
1463-
local cluster=$(oc config view --minify --output jsonpath='{..server}')
1464-
oc login "${cluster}" --token="${oc_token}"
1463+
local cluster=$(oc config view --minify -o jsonpath='{..server}')
1464+
local namespace=$(oc config view --minify -o jsonpath='{..namespace}')
1465+
export KUBECONFIG="${KUBECONFIG_FILE:-${PWD}/.kubeconfig}"
1466+
oc login "${cluster}" --token="${oc_token}" -n "${namespace}" --insecure-skip-tls-verify
14651467
trap_add "brlog 'INFO' 'You currently oc login as a scripts ServiceAccount. You can rerun scripts with this. Please delete ServiceAccount ${BACKUP_RESTORE_SA} and clusterrolebinding ${BACKUP_RESTORE_SA}-cluster-rb when you complete backup or restore'"
14661468

14671469
}

discovery-data/latest/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
The Backup and Restore Scripts for the Watson Discovery on CP4D.
2-
Scripts Version: 4.8.4
2+
Scripts Version: 4.8.5

0 commit comments

Comments
 (0)