Skip to content

Commit

Permalink
only pause after short runs if running as a daemon.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Mar 13, 2024
1 parent 38266f4 commit 786ca75
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,27 +490,17 @@ func execProviderBackups() {

notify(backupResults, succeeded, failed)

// help avoid thrashing provider apis if job auto-restarts
// after an early failure by adding delay if backup took less than 10 seconds
if time.Since(startTime) < time.Second*defaultEarlyErrorBackOffSeconds {
logger.Printf("backup took less than 10 seconds, "+
"waiting %d seconds before next run to avoid thrashing"+
" provider apis", defaultEarlyErrorBackOffSeconds)

time.Sleep(time.Second * defaultEarlyErrorBackOffSeconds)
}

// help avoid thrashing provider apis if job auto-restartsrestarts
// after an early failure by adding delay if backup took less than 10 seconds
if time.Since(startTime) < time.Second*defaultEarlyErrorBackOffSeconds {
logger.Printf("backup took less than 10 seconds, "+
"waiting %d seconds before next run to avoid thrashing"+
" provider apis", defaultEarlyErrorBackOffSeconds)

time.Sleep(time.Second * defaultEarlyErrorBackOffSeconds)
}

if backupInterval := getBackupInterval(); backupInterval > 0 {
// help avoid thrashing provider apis if job auto-restartsrestarts
// after an early failure by adding delay if backup took less than 10 seconds
if time.Since(startTime) < time.Second*defaultEarlyErrorBackOffSeconds {
logger.Printf("backup took less than 10 seconds, "+
"waiting %d seconds before next run to avoid thrashing"+
" provider apis", defaultEarlyErrorBackOffSeconds)

time.Sleep(time.Second * defaultEarlyErrorBackOffSeconds)
}

nextBackupTime := startTime.Add(time.Duration(backupInterval) * time.Minute)
if nextBackupTime.Before(time.Now()) {
logger.Fatal("error: backup took longer than scheduled interval")
Expand Down

0 comments on commit 786ca75

Please sign in to comment.