File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ SPLIT_DIR=./tmp_split_backup
88EXTRA_OC_ARGS=" ${EXTRA_OC_ARGS:- } "
99
1010SCRIPT_DIR=$( dirname $0 )
11+ KUBECONFIG_FILE=" ${SCRIPT_DIR} /.kubeconfig"
1112
1213. ${SCRIPT_DIR} /lib/function.bash
1314
504505brlog " INFO" " Clean up"
505506
506507delete_service_account " ${BACKUP_RESTORE_SA} "
508+ rm -f " ${KUBECONFIG_FILE} "
509+ unset KUBECONFIG
507510rm -rf " ${BACKUP_DIR} "
508511
509512disable_trap
Original file line number Diff line number Diff 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+
3539if [ $# -lt 2 ] ; then
3640 printUsage
3741fi
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)
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
Original file line number Diff line number Diff line change @@ -1460,8 +1460,10 @@ delete_service_account(){
14601460oc_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}
Original file line number Diff line number Diff line change 11The Backup and Restore Scripts for the Watson Discovery on CP4D.
2- Scripts Version: 4.8.4
2+ Scripts Version: 4.8.5
You can’t perform that action at this time.
0 commit comments