fix: Duplicated restores

This commit is contained in:
Dion 2024-06-20 12:48:17 -04:00
parent e40032497b
commit 20246998da
No known key found for this signature in database
GPG Key ID: A5E0435C957FCD52
1 changed files with 7 additions and 6 deletions

View File

@ -180,12 +180,7 @@ func (bar *BackupAndRestore) Restore(jenkinsClient jenkinsclient.Jenkins) error
if err != nil {
return err
}
//TODO fix me because we're doing two saves unatomically
jenkins.Spec.Restore.RecoveryOnce = 0
err = bar.Client.Update(context.TODO(), jenkins)
if err != nil {
return err
}
key := types.NamespacedName{
Namespace: jenkins.Namespace,
Name: jenkins.Name,
@ -194,6 +189,12 @@ func (bar *BackupAndRestore) Restore(jenkinsClient jenkinsclient.Jenkins) error
if err != nil {
return err
}
jenkins.Spec.Restore.RecoveryOnce = 0
err = bar.Client.Update(context.TODO(), jenkins)
if err != nil {
return err
}
bar.Configuration.Jenkins = jenkins
jenkins.Status.RestoredBackup = backupNumber