@@ -232,14 +232,15 @@ wait_backup() {
232
232
echo -n .
233
233
let retry+=1
234
234
current_status=$( kubectl_bin get psmdb-backup $backup_name -o jsonpath=' {.status.state}' )
235
- if [[ $retry -ge 360 || ${current_status} == ' error' ]]; then
235
+ if [[ $retry -ge 600 || ${current_status} == ' error' ]]; then
236
236
kubectl_bin logs ${OPERATOR_NS: +-n $OPERATOR_NS } $( get_operator_pod) \
237
237
| grep -v ' level=info' \
238
238
| grep -v ' level=debug' \
239
239
| grep -v ' Getting tasks for pod' \
240
240
| grep -v ' Getting pods from source' \
241
- | tail -100
242
- echo " Backup object psmdb-backup/${backup_name} is in ${current_state} state."
241
+ | tail -200
242
+ kubectl_bin get psmdb-backup
243
+ echo " Backup object psmdb-backup/${backup_name} is in ${current_status} state."
243
244
echo something went wrong with operator or kubernetes cluster
244
245
exit 1
245
246
fi
@@ -348,26 +349,40 @@ wait_restore() {
348
349
local ok_if_ready=${6:- 0}
349
350
350
351
set +o xtrace
352
+ # We need to run wait till object is created, otherwise wait fails at once
353
+ echo -n " Waiting for the psmdb-restore/restore-$backup_name object to be created"
354
+ retry_object=0
355
+ until kubectl_bin get psmdb-restore restore-$backup_name > /dev/null 2>&1 ; do
356
+ echo -n .
357
+ let retry_object+=1
358
+ if [[ ${retry_object} -ge 60 ]]; then
359
+ echo " psmdb-restore/restore-$backup_name object was not created."
360
+ exit 1
361
+ fi
362
+ sleep 1
363
+ done
364
+ echo " OK"
365
+
366
+ echo -n " Waiting psmdb-restore/restore-${backup_name} to reach state \" ${target_state} \" "
351
367
retry=0
352
- echo -n " waiting psmdb-restore/restore-${backup_name} to reach ${target_state} state"
353
- local current_state=
354
- until [[ ${current_state} == ${target_state} ]]; do
355
- sleep 0.5
368
+ retry_count=$(( wait_time / 60 ))
369
+ until kubectl wait psmdb-restore restore-${backup_name} --for=jsonpath=' {.status.state}' =${target_state} --timeout=60s > /dev/null 2>&1 ; do
356
370
echo -n .
357
371
let retry+=1
358
372
current_state=$( kubectl_bin get psmdb-restore restore-$backup_name -o jsonpath=' {.status.state}' )
359
373
if [[ ${ok_if_ready} == 1 && ${current_state} == ' ready' ]]; then
360
374
echo " OK"
361
375
break
362
376
fi
363
- if [[ $retry -ge $wait_time || ${current_state} == ' error' ]]; then
377
+ if [[ ${ retry} -ge ${retry_count} || ${current_state} == ' error' ]]; then
364
378
kubectl_bin logs ${OPERATOR_NS: +-n $OPERATOR_NS } $( get_operator_pod) \
365
379
| grep -v ' level=info' \
366
380
| grep -v ' level=debug' \
367
381
| grep -v ' Getting tasks for pod' \
368
382
| grep -v ' Getting pods from source' \
369
383
| tail -100
370
384
kubectl_bin get psmdb-restore restore-${backup_name} -o yaml
385
+ kubectl_bin describe psmdb-restore restore-${backup_name}
371
386
echo " Restore object restore-${backup_name} is in ${current_state} state."
372
387
echo something went wrong with operator or kubernetes cluster
373
388
exit 1
@@ -376,7 +391,7 @@ wait_restore() {
376
391
echo " OK"
377
392
set_debug
378
393
379
- if [ $wait_cluster_consistency -eq 1 ]; then
394
+ if [[ $wait_cluster_consistency -eq 1 ] ]; then
380
395
wait_cluster_consistency " ${cluster_name} "
381
396
fi
382
397
}
@@ -1023,6 +1038,14 @@ delete_crd() {
1023
1038
kubectl_bin delete -f " ${src_dir} /deploy/$rbac_yaml " --ignore-not-found || true
1024
1039
}
1025
1040
1041
+ delete_backups () {
1042
+ desc ' Delete psmdb-backup'
1043
+ if [ $( kubectl_bin get psmdb-backup --no-headers | wc -l) != 0 ]; then
1044
+ kubectl_bin get psmdb-backup
1045
+ kubectl_bin delete psmdb-backup --all
1046
+ fi
1047
+ }
1048
+
1026
1049
destroy () {
1027
1050
local namespace=" $1 "
1028
1051
local ignore_logs=" ${2:- true} "
@@ -1043,6 +1066,8 @@ destroy() {
1043
1066
# TODO: maybe will be enabled later
1044
1067
# diff $test_dir/compare/operator.log $tmp_dir/operator.log
1045
1068
1069
+ delete_backups
1070
+
1046
1071
delete_crd
1047
1072
1048
1073
destroy_cert_manager || true
0 commit comments