DEV: Restore missing_s3_uploads stats count if site was restored (#27984)

This commit ensures that we reset the `missing_s3_uploads` status count
if there are no inventory files which are at least 2 days older than the
site's restored date.

Otherwise, a site with missing uploads but was subsequntly restored will
be continue to report missing uploads for 2 days.
This commit is contained in:
Alan Guo Xiang Tan
2024-07-19 14:22:58 +08:00
committed by GitHub
parent f5cbc3e3b8
commit 5038cad68e
2 changed files with 11 additions and 2 deletions

View File

@ -169,7 +169,9 @@ RSpec.describe S3Inventory do
capture_stdout { inventory.backfill_etags_and_list_missing }
end
it "should not run if inventory files are not at least #{described_class::WAIT_AFTER_RESTORE_DAYS.days} days older than the last restore date" do
it "should not run if inventory files are not at least #{described_class::WAIT_AFTER_RESTORE_DAYS.days} days older than the last restore date and reset stats count" do
Discourse.stats.set("missing_s3_uploads", 2)
inventory.s3_client.stub_responses(
:list_objects_v2,
{
@ -186,6 +188,8 @@ RSpec.describe S3Inventory do
inventory.s3_client.expects(:get_object).never
capture_stdout { inventory.backfill_etags_and_list_missing }
expect(Discourse.stats.get("missing_s3_uploads")).to eq(0)
end
end