Skip to content

Commit

Permalink
Cleaned up some of the logging on the historical delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tkmcmaster committed Dec 27, 2023
1 parent ede686c commit 3ddc5b4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions controller/pages/api/util/testscheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,13 @@ export class TestScheduler implements TestSchedulerItem {
}

protected static async runHistoricalDelete (deleteOldFilesDays: number = DELETE_OLD_FILES_DAYS): Promise<number> {
let deletedCount: number = 0;
try {
let deletedCount: number = 0;
// Load existing ones
await TestScheduler.loadHistoricalFromS3();
const oldDatetime: number = Date.now() - (deleteOldFilesDays * ONE_DAY);
log("Starting Test Historical Delete", LogLevel.INFO, { sizeBefore: TestScheduler.historicalTests!.size, oldDatetime: new Date(oldDatetime), deleteOldFilesDays });
const sizeBefore = TestScheduler.historicalTests!.size;
log("Starting Test Historical Delete", LogLevel.INFO, { sizeBefore, oldDatetime: new Date(oldDatetime), deleteOldFilesDays });

// Delete old ones off the historical Calendar. These will be cleaned up in S3 by Bucket Expiration Policy
for (const [testId, eventInput] of TestScheduler.historicalTests!) {
Expand All @@ -880,10 +881,10 @@ export class TestScheduler implements TestSchedulerItem {
}
}
await TestScheduler.saveHistoricalToS3();
log("Finished Test Historical Delete", LogLevel.INFO, { sizeAfter: TestScheduler.historicalTests!.size });
log("Finished Test Historical Delete", LogLevel.INFO, { deletedCount, sizeBefore, sizeAfter: TestScheduler.historicalTests!.size });
return deletedCount;
} catch (error) {
log("Error running Historical Delete", LogLevel.ERROR, error);
log("Error running Historical Delete", LogLevel.ERROR, error, { deletedCount });
throw error; // Throw for testing, but the loop will catch and noop
}
}
Expand Down

0 comments on commit 3ddc5b4

Please sign in to comment.