diff --git a/pkg/core/dump.go b/pkg/core/dump.go index f62047f..d0c8573 100644 --- a/pkg/core/dump.go +++ b/pkg/core/dump.go @@ -185,6 +185,8 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err uploadSpan.SetStatus(codes.Ok, "completed") uploadSpan.End() + logger.Infof("finished dump %s", now.Format(time.RFC3339)) + return results, nil } diff --git a/pkg/core/timer.go b/pkg/core/timer.go index 1d3723d..d3bff6b 100644 --- a/pkg/core/timer.go +++ b/pkg/core/timer.go @@ -21,12 +21,14 @@ type Update struct { // Last whether or not this is the last update, and no more will be coming. // If true, perform this action and then end. Last bool + // Next time until the next update, if applicable. + Next time.Duration } -func sendTimer(c chan Update, last bool) { +func sendTimer(c chan Update, last bool, next time.Duration) { // make the channel write non-blocking select { - case c <- Update{Last: last}: + case c <- Update{Last: last, Next: next}: default: } } @@ -66,7 +68,7 @@ func Timer(opts TimerOptions) (<-chan Update, error) { // if once, ignore all delays and go if opts.Once { - sendTimer(c, true) + sendTimer(c, true, 0) return } @@ -74,9 +76,6 @@ func Timer(opts TimerOptions) (<-chan Update, error) { for { lastRun := time.Now().UTC() - // not once - run the first backup - sendTimer(c, false) - if opts.Cron != "" { now := time.Now().UTC() delay, _ = waitForCron(opts.Cron, now) @@ -95,6 +94,9 @@ func Timer(opts TimerOptions) (<-chan Update, error) { delay = time.Duration(opts.Frequency-passed) * time.Minute } + // not once - run the first backup + sendTimer(c, false, delay) + // if delayMins is 0, this will do nothing, so it does not hurt time.Sleep(delay) } @@ -178,6 +180,7 @@ func (e *Executor) Timer(timerOpts TimerOptions, cmd func() error) error { if update.Last { break } + e.Logger.Infof("next run in %s", update.Next.String()) } return nil }