Fix non-recurring backups (#509)
diff --git a/controllers/solrbackup_controller.go b/controllers/solrbackup_controller.go
index b73fd16..dfffd52 100644
--- a/controllers/solrbackup_controller.go
+++ b/controllers/solrbackup_controller.go
@@ -92,17 +92,18 @@
requeueOrNot := reconcile.Result{}
- var backupNeedsToWait bool
+ // Backup work needs to be done by default if the current backup is not finished
+ doBackupWork := !backup.Status.IndividualSolrBackupStatus.Finished
// Check if we should start the next backup
- if backup.Status.NextScheduledTime != nil {
- // If the backup no longer enabled, remove the next scheduled time
+ // Do not check if already doing a backup
+ if !doBackupWork && backup.Status.NextScheduledTime != nil {
if !backup.Spec.Recurrence.IsEnabled() {
backup.Status.NextScheduledTime = nil
- backupNeedsToWait = false
+ doBackupWork = false
} else if backup.Status.NextScheduledTime.UTC().Before(time.Now().UTC()) {
// We have hit the next scheduled restart time.
- backupNeedsToWait = false
+ doBackupWork = true
backup.Status.NextScheduledTime = nil
// Add the current backup to the front of the history.
@@ -119,14 +120,12 @@
} else {
// If we have not hit the next scheduled restart, wait to requeue until that is true.
updateRequeueAfter(&requeueOrNot, backup.Status.NextScheduledTime.UTC().Sub(time.Now().UTC()))
- backupNeedsToWait = true
+ doBackupWork = false
}
- } else {
- backupNeedsToWait = false
}
- // Do backup work if we are not waiting and the current backup is not finished
- if !backupNeedsToWait && !backup.Status.IndividualSolrBackupStatus.Finished {
+ // Do backup work if a backup is in-progress or needs to be started
+ if doBackupWork {
solrCloud, _, err1 := r.reconcileSolrCloudBackup(ctx, backup, &backup.Status.IndividualSolrBackupStatus, logger)
if err1 != nil {
// TODO Should we be failing the backup for some sub-set of errors here?
@@ -146,7 +145,7 @@
}
// Schedule the next backupTime, if it doesn't have a next scheduled time, it has recurrence and the current backup is finished
- if backup.Status.IndividualSolrBackupStatus.Finished {
+ if backup.Status.IndividualSolrBackupStatus.Finished && backup.Spec.Recurrence.IsEnabled() {
if nextBackupTime, err1 := util.ScheduleNextBackup(backup.Spec.Recurrence.Schedule, backup.Status.IndividualSolrBackupStatus.StartTime.Time); err1 != nil {
logger.Error(err1, "Could not update backup scheduling due to bad cron schedule", "cron", backup.Spec.Recurrence.Schedule)
} else {
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index 6b45ffc..bf82466 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -89,6 +89,11 @@
links:
- name: GitHub PR
url: https://github.com/apache/solr-operator/pull/512/files
+ - kind: fixed
+ description: Fix bug in non-recurring SolrBackups
+ links:
+ - name: GitHub PR
+ url: https://github.com/apache/solr-operator/pull/509
artifacthub.io/images: |
- name: solr-operator
image: apache/solr-operator:v0.7.0-prerelease