Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions controllers/solrbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,18 @@ func (r *SolrBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request)

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.
Expand All @@ -119,14 +120,12 @@ func (r *SolrBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
} 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?
Expand All @@ -146,7 +145,7 @@ func (r *SolrBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}

// 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() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[+1] Weird that the comment on L147 mentions recurrence-being-enabled as being a prereq, but we never checked for it before now. Must've just been an oversight on my part?

Anyway, good catch!

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 {
Expand Down
5 changes: 5 additions & 0 deletions helm/solr-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ annotations:
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
Expand Down