Skip to content

Commit 146e6e1

Browse files
egeguneshorspooknull
authored
K8SPSMDB-1065: Fix checking oplog slicing locks (#1511)
* K8SPSMDB-1065: Fix checking oplog slicing locks * fix pitr test * fix `get_latest_restorable_time` --------- Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com> Co-authored-by: Andrii Dema <a.dema@jazzserve.com>
1 parent af550c2 commit 146e6e1

File tree

3 files changed

+9
-27
lines changed

3 files changed

+9
-27
lines changed

e2e-tests/functions

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,11 +1460,10 @@ get_latest_restorable_time() {
14601460
# "pbm-agent status" can return different timestamp in first few seconds
14611461
# we need to get it twice to be sure that timestamp was not changed
14621462
until [[ $first_timestamp != "" && $first_timestamp != "null" && $first_timestamp == $second_timestamp ]]; do
1463+
first_timestamp=$(kubectl_bin exec "$cluster-0" -c backup-agent -- pbm status -o json | jq '.backups.pitrChunks.pitrChunks | last | .range.end')
14631464
sleep 5
14641465
if [[ $first_timestamp != "" && $first_timestamp != "null" ]]; then
14651466
second_timestamp=$(kubectl_bin exec "$cluster-0" -c backup-agent -- pbm status -o json | jq '.backups.pitrChunks.pitrChunks | last | .range.end')
1466-
else
1467-
first_timestamp=$(kubectl_bin exec "$cluster-0" -c backup-agent -- pbm status -o json | jq '.backups.pitrChunks.pitrChunks | last | .range.end')
14681467
fi
14691468
let retry+=1
14701469
if [[ $retry -gt 30 ]]; then

e2e-tests/pitr/run

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,6 @@ check_recovery() {
9393
compare_mongo_cmd "find" "myApp:myPass@$cluster-2.$cluster.$namespace" "$cmp_postfix"
9494
}
9595

96-
get_latest_restorable_time() {
97-
local cluster=$1
98-
local timestamp
99-
100-
timestamp=$(kubectl exec "$cluster-0" -c backup-agent -- pbm status -o json | jq '.backups.pitrChunks.pitrChunks | last | .range.end')
101-
102-
$date -u -d @"$timestamp" "+%Y-%m-%dT%H:%M:%SZ"
103-
}
104-
105-
compare_latest_restorable_time() {
106-
local cluster=$1
107-
local backup_name=$2
108-
local latest_restorable_time
109-
latest_restorable_time=$(get_latest_restorable_time "$cluster")
110-
local backup_time
111-
backup_time=$(kubectl get psmdb-backup "$backup_name" -o jsonpath='{.status.latestRestorableTime}')
112-
113-
if [[ $latest_restorable_time != "$backup_time" ]]; then
114-
echo "Error: latestRestorableTime is not equal to the latest timestamp of the backup $backup_name: $latest_restorable_time != $backup_time"
115-
exit 1
116-
fi
117-
118-
}
119-
12096
main() {
12197
create_infra $namespace
12298
deploy_minio

pkg/psmdb/backup/pbm.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,16 @@ func NotJobLock(j Job) LockHeaderPredicate {
389389
func (b *pbmC) HasLocks(ctx context.Context, predicates ...LockHeaderPredicate) (bool, error) {
390390
locks, err := lock.GetLocks(ctx, b.Client, &lock.LockHeader{})
391391
if err != nil {
392-
return false, errors.Wrap(err, "getting lock data")
392+
return false, errors.Wrap(err, "get lock data")
393393
}
394394

395+
opLocks, err := lock.GetOpLocks(ctx, b.Client, &lock.LockHeader{})
396+
if err != nil {
397+
return false, errors.Wrap(err, "get op lock data")
398+
}
399+
400+
locks = append(locks, opLocks...)
401+
395402
allowedByAllPredicates := func(l lock.LockHeader) bool {
396403
for _, allow := range predicates {
397404
if !allow(l) {

0 commit comments

Comments
 (0)