maintenance: fail when the maintenance schedule cannot be read
@@ -175,6 +175,15 @@ func SetSchedule(ctx context.Context, rep repo.DirectRepositoryWriter, s *Schedu
// ReportRun reports timing of a maintenance run and persists it in repository.
func ReportRun(ctx context.Context, rep repo.DirectRepositoryWriter, taskType TaskType, s *Schedule, run func() error) error {
+ if s == nil {
+ var err error
+
+ s, err = GetSchedule(ctx, rep)
+ if err != nil {
+ return errors.Wrap(err, "unable to get maintenance schedule")
+ }
+ }
+
ri := RunInfo{
Start: rep.Time(),
}
@@ -189,15 +198,6 @@ func ReportRun(ctx context.Context, rep repo.DirectRepositoryWriter, taskType Ta
ri.Success = true
}
- if s == nil {
- var err error
-
- s, err = GetSchedule(ctx, rep)
- if err != nil {
- log(ctx).Errorf("unable to get schedule")
- }
- }
-
s.ReportRun(taskType, ri)
if err := SetSchedule(ctx, rep, s); err != nil {
