Skip to content

Commit f9354c4

Browse files
committed
wait after adding resync annotation
1 parent 3cd0736 commit f9354c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/controller/perconaservermongodbrestore/physical.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (r *ReconcilePerconaServerMongoDBRestore) reconcilePhysicalRestore(
289289
finished, err := r.finishPhysicalRestore(ctx, cluster)
290290
if err != nil {
291291
log.Error(err, "Failed to recover the cluster after the restore")
292-
status.State = psmdbv1.RestoreStateReady
292+
// status.State = psmdbv1.RestoreStateReady
293293
return status, nil
294294
}
295295
if !finished {
@@ -400,6 +400,7 @@ func (r *ReconcilePerconaServerMongoDBRestore) finishPhysicalRestore(ctx context
400400
return false, nil
401401
}
402402

403+
resyncPresent := false
403404
if err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
404405
c := new(psmdbv1.PerconaServerMongoDB)
405406
if err := r.client.Get(ctx, client.ObjectKeyFromObject(cluster), c); err != nil {
@@ -409,12 +410,20 @@ func (r *ReconcilePerconaServerMongoDBRestore) finishPhysicalRestore(ctx context
409410
if c.Annotations == nil {
410411
c.Annotations = make(map[string]string)
411412
}
413+
if c.Annotations[psmdbv1.AnnotationResyncPBM] == "true" {
414+
resyncPresent = true
415+
return nil
416+
}
417+
412418
c.Annotations[psmdbv1.AnnotationResyncPBM] = "true"
413419

414420
return r.client.Update(ctx, c)
415421
}); err != nil {
416422
return false, errors.Wrapf(err, "annotate psmdb/%s for PBM resync", cluster.Name)
417423
}
424+
if !resyncPresent {
425+
return false, nil
426+
}
418427

419428
if err := r.updateMongodSts(ctx, cluster, func(sts *appsv1.StatefulSet) error {
420429
if sts.Annotations[psmdbv1.AnnotationRestoreInProgress] == "true" {

0 commit comments

Comments
 (0)