Skip to content

Commit

Permalink
Merge pull request #1648 from flanksource/fix-range-error
Browse files Browse the repository at this point in the history
fix: cleanup canary out of range error
  • Loading branch information
moshloop authored Feb 2, 2024
2 parents 0cdd1ac + d04a1ac commit 9c34c97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/topology/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ var CleanupCanaries = &job.Job{
Retention: job.Retention3Day,
RunNow: true,
Fn: func(ctx job.JobRuntime) error {
retention := ctx.Properties().Duration("canary.retention.age", DefaultRetention)
tx := ctx.DB().Exec(`
DELETE FROM canaries
WHERE
id NOT IN (SELECT canary_id FROM checks) AND
(NOW() - deleted_at) > INTERVAL '1 day' * ?
`, ctx.Properties().Duration("canary.retention.age", DefaultRetention))
(NOW() - deleted_at) > INTERVAL '1 second' * ?
`, int64(retention.Seconds()))

ctx.History.SuccessCount = int(tx.RowsAffected)
return tx.Error
Expand Down

0 comments on commit 9c34c97

Please sign in to comment.