Skip to content

Commit 788505c

Browse files
committed
backoff wait after adding resync
1 parent f9354c4 commit 788505c

File tree

5 files changed

+25
-8
lines changed
  • e2e-tests
    • demand-backup-incremental-sharded
    • demand-backup-incremental
    • demand-backup-physical-sharded
    • demand-backup-physical
  • pkg/controller/perconaservermongodbrestore

5 files changed

+25
-8
lines changed

e2e-tests/demand-backup-incremental-sharded/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ run_recovery_check() {
5050
# we don't wait for cluster readiness here because the annotation gets removed then
5151
wait_restore "${backup_name}" "${cluster}" "ready" "0" "3000"
5252

53-
sleep 5
53+
sleep 15
5454

5555
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
5656
log "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a incremental restore"

e2e-tests/demand-backup-incremental/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ run_recovery_check() {
5050
# we don't wait for cluster readiness here because the annotation gets removed then
5151
wait_restore "${backup_name}" "${cluster}" "ready" "0" "1800"
5252

53-
sleep 5
53+
sleep 15
5454

5555
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
5656
log "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a incremental restore"

e2e-tests/demand-backup-physical-sharded/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ run_recovery_check() {
3737
# we don't wait for cluster readiness here because the annotation gets removed then
3838
wait_restore "${backup_name}" "${cluster}" "ready" "0" "3000"
3939

40-
sleep 5
40+
sleep 15
4141

4242
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
4343
echo "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a physical restore"

e2e-tests/demand-backup-physical/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ run_recovery_check() {
3737
# we don't wait for cluster readiness here because the annotation gets removed then
3838
wait_restore "${backup_name}" "${cluster}" "ready" "0" "1800"
3939

40-
sleep 5
40+
sleep 15
4141

4242
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
4343
echo "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a physical restore"

pkg/controller/perconaservermongodbrestore/physical.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ func (r *ReconcilePerconaServerMongoDBRestore) finishPhysicalRestore(ctx context
400400
return false, nil
401401
}
402402

403-
resyncPresent := false
404403
if err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
405404
c := new(psmdbv1.PerconaServerMongoDB)
406405
if err := r.client.Get(ctx, client.ObjectKeyFromObject(cluster), c); err != nil {
@@ -411,7 +410,6 @@ func (r *ReconcilePerconaServerMongoDBRestore) finishPhysicalRestore(ctx context
411410
c.Annotations = make(map[string]string)
412411
}
413412
if c.Annotations[psmdbv1.AnnotationResyncPBM] == "true" {
414-
resyncPresent = true
415413
return nil
416414
}
417415

@@ -421,8 +419,27 @@ func (r *ReconcilePerconaServerMongoDBRestore) finishPhysicalRestore(ctx context
421419
}); err != nil {
422420
return false, errors.Wrapf(err, "annotate psmdb/%s for PBM resync", cluster.Name)
423421
}
424-
if !resyncPresent {
425-
return false, nil
422+
423+
err = retry.OnError(retry.DefaultBackoff, func(err error) bool {
424+
return err != nil
425+
}, func() error {
426+
c := new(psmdbv1.PerconaServerMongoDB)
427+
if err := r.client.Get(ctx, client.ObjectKeyFromObject(cluster), c); err != nil {
428+
return err
429+
}
430+
431+
if c.Annotations == nil {
432+
return errors.New("annotation wasn't added")
433+
}
434+
435+
if v, ok := c.Annotations[psmdbv1.AnnotationResyncPBM]; !ok || v != "true" {
436+
return errors.New("annotation wasn't added 2")
437+
}
438+
439+
return nil
440+
})
441+
if err != nil {
442+
return false, errors.Wrap(err, "failed to check if annotation was added")
426443
}
427444

428445
if err := r.updateMongodSts(ctx, cluster, func(sts *appsv1.StatefulSet) error {

0 commit comments

Comments
 (0)