Skip to content

Commit

Permalink
Merge branch 'master' into backup-restore-fix-operator-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 authored Jun 25, 2024
2 parents 5f5c8e1 + 5ef6c73 commit c98c5a2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/configuration/backuprestore/backuprestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -223,6 +224,15 @@ func (bar *BackupAndRestore) Backup(setBackupDoneBeforePodDeletion bool) error {
_, _, err := bar.Exec(podName, jenkins.Spec.Backup.ContainerName, command)

if err == nil {
key := types.NamespacedName{
Namespace: jenkins.Namespace,
Name: jenkins.Name,
}
err = bar.Client.Get(context.TODO(), key, jenkins)
if err != nil {
return err
}

bar.logger.V(log.VDebug).Info(fmt.Sprintf("Backup completed '%d', updating status", backupNumber))
if jenkins.Status.RestoredBackup == 0 {
jenkins.Status.RestoredBackup = backupNumber
Expand Down

0 comments on commit c98c5a2

Please sign in to comment.