Adjust max age for cron stats entries (#9190)
This commit is contained in:
@@ -85,7 +85,7 @@ func (ds *Datastore) UpdateAllCronStatsForInstance(ctx context.Context, instance
|
||||
|
||||
func (ds *Datastore) CleanupCronStats(ctx context.Context) error {
|
||||
deleteStmt := `DELETE FROM cron_stats WHERE created_at < DATE_SUB(NOW(), INTERVAL ? DAY)`
|
||||
const MAX_DAYS_RETAINED = 14
|
||||
const MAX_DAYS_RETAINED = 2
|
||||
if _, err := ds.writer.ExecContext(ctx, deleteStmt, MAX_DAYS_RETAINED); err != nil {
|
||||
return ctxerr.Wrap(ctx, err, "deleting old cron stats")
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestCleanupCronStats(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ds := CreateMySQLDS(t)
|
||||
now := time.Now().UTC().Truncate(time.Second)
|
||||
twoWeeksAgo := now.Add(-14 * 24 * time.Hour)
|
||||
twoDaysAgo := now.Add(-2 * 24 * time.Hour)
|
||||
name := "test_sched"
|
||||
instance := "test_instance"
|
||||
|
||||
@@ -152,13 +152,13 @@ func TestCleanupCronStats(t *testing.T) {
|
||||
shouldCleanupMaxAge: false,
|
||||
},
|
||||
{
|
||||
createdAt: twoWeeksAgo.Add(1 * time.Hour),
|
||||
createdAt: twoDaysAgo.Add(1 * time.Hour),
|
||||
status: fleet.CronStatsStatusCompleted,
|
||||
shouldCleanupMaxPending: false,
|
||||
shouldCleanupMaxAge: false,
|
||||
},
|
||||
{
|
||||
createdAt: twoWeeksAgo.Add(-1 * time.Hour),
|
||||
createdAt: twoDaysAgo.Add(-1 * time.Hour),
|
||||
status: fleet.CronStatsStatusCompleted,
|
||||
shouldCleanupMaxPending: false,
|
||||
shouldCleanupMaxAge: true,
|
||||
|
||||
Reference in New Issue
Block a user