@@ -1449,29 +1449,54 @@ start_cluster() {
1449
1449
1450
1450
get_latest_restorable_time () {
1451
1451
local cluster=$1
1452
- local timestamp
1453
- local timeout
1452
+ local first_timestamp
1453
+ local second_timestamp
1454
+ local retry=0
1454
1455
1455
- until [[ $timestamp != " " && $timestamp != " null" ]]; do
1456
+ # "pbm-agent status" can return different timestamp in first few seconds
1457
+ # we need to get it twice to be sure that timestamp was not changed
1458
+ until [[ $first_timestamp != " " && $first_timestamp != " null" && $first_timestamp == $second_timestamp ]]; do
1456
1459
sleep 5
1457
- timestamp=$( kubectl exec " $cluster -0" -c backup-agent -- pbm status -o json | jq ' .backups.pitrChunks.pitrChunks | last | .range.end' )
1458
- timeout=$(( timeout + 5 ))
1459
- if [[ $timeout -gt 30 ]]; then
1460
+ if [[ $first_timestamp != " " && $first_timestamp != " null" ]]; then
1461
+ second_timestamp=$( kubectl_bin exec " $cluster -0" -c backup-agent -- pbm status -o json | jq ' .backups.pitrChunks.pitrChunks | last | .range.end' )
1462
+ else
1463
+ first_timestamp=$( kubectl_bin exec " $cluster -0" -c backup-agent -- pbm status -o json | jq ' .backups.pitrChunks.pitrChunks | last | .range.end' )
1464
+ fi
1465
+ let retry+=1
1466
+ if [[ $retry -gt 30 ]]; then
1460
1467
echo " Error: timeout waiting for timestamp"
1461
1468
exit 1
1462
1469
fi
1463
1470
done
1464
1471
1465
- $date -u -d @" $timestamp " " +%Y-%m-%dT%H:%M:%SZ"
1472
+ $date -u -d @" $first_timestamp " " +%Y-%m-%dT%H:%M:%SZ"
1466
1473
}
1467
1474
1475
+ get_latest_restorable_time_from_backup_object () {
1476
+ local backup_name=$1
1477
+ local latestRestorableTime
1478
+ local retry=0
1479
+
1480
+ until [[ $latestRestorableTime != " " && $latestRestorableTime != " null" ]]; do
1481
+ sleep 5
1482
+ latestRestorableTime=$( kubectl_bin get psmdb-backup " $backup_name " -o jsonpath=' {.status.latestRestorableTime}' )
1483
+ let retry+=1
1484
+ if [[ $retry -gt 30 ]]; then
1485
+ echo " Error: timeout waiting for latestRestorableTime"
1486
+ exit 1
1487
+ fi
1488
+ done
1489
+
1490
+ echo " $latestRestorableTime "
1491
+ }
1468
1492
compare_latest_restorable_time () {
1469
1493
local cluster=$1
1470
1494
local backup_name=$2
1471
1495
local latest_restorable_time
1472
- latest_restorable_time=$( get_latest_restorable_time " $cluster " )
1473
1496
local backup_time
1474
- backup_time=$( kubectl get psmdb-backup " $backup_name " -o jsonpath=' {.status.latestRestorableTime}' )
1497
+
1498
+ latest_restorable_time=$( get_latest_restorable_time " $cluster " )
1499
+ backup_time=$( get_latest_restorable_time_from_backup_object " $backup_name " )
1475
1500
1476
1501
if [[ $latest_restorable_time != " $backup_time " ]]; then
1477
1502
echo " Error: latestRestorableTime is not equal to the latest timestamp of the backup $backup_name : $latest_restorable_time != $backup_time "
0 commit comments