Chore: Remove context.TODO() from services (#42555)

* Remove context.TODO() from services

* Fix live test
This commit is contained in:
idafurjes
2021-12-20 17:05:33 +01:00
committed by GitHub
parent 6f8e651cdb
commit ff3cf94b56
23 changed files with 78 additions and 75 deletions
+3 -3
View File
@@ -47,7 +47,7 @@ func (srv *CleanUpService) Run(ctx context.Context) error {
defer cancelFn()
srv.cleanUpTmpFiles()
srv.deleteExpiredSnapshots()
srv.deleteExpiredSnapshots(ctx)
srv.deleteExpiredDashboardVersions(ctx)
srv.cleanUpOldAnnotations(ctxWithTimeout)
srv.expireOldUserInvites(ctx)
@@ -125,9 +125,9 @@ func (srv *CleanUpService) shouldCleanupTempFile(filemtime time.Time, now time.T
return filemtime.Add(srv.Cfg.TempDataLifetime).Before(now)
}
func (srv *CleanUpService) deleteExpiredSnapshots() {
func (srv *CleanUpService) deleteExpiredSnapshots(ctx context.Context) {
cmd := models.DeleteExpiredSnapshotsCommand{}
if err := bus.DispatchCtx(context.TODO(), &cmd); err != nil {
if err := bus.DispatchCtx(ctx, &cmd); err != nil {
srv.log.Error("Failed to delete expired snapshots", "error", err.Error())
} else {
srv.log.Debug("Deleted expired snapshots", "rows affected", cmd.DeletedRows)