mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Prevent "uploads are missing in S3" alerts after restoring a backup
After restoring a backup it takes up to 48 hours for uploads stored on S3 to appear in the S3 inventory. This change prevents alerts about missing uploads by preventing the EnsureS3UploadsExistence job from running in the first 48 hours after a restore. During the restore it deletes the count of missing uploads from the PluginStore, so that an alert isn't triggered by an old number.
This commit is contained in:
42
spec/jobs/ensure_s3_uploads_existence_spec.rb
Normal file
42
spec/jobs/ensure_s3_uploads_existence_spec.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Jobs::EnsureS3UploadsExistence do
|
||||
context "S3 inventory enabled" do
|
||||
before do
|
||||
SiteSetting.enable_s3_uploads = true
|
||||
SiteSetting.s3_access_key_id = "abc"
|
||||
SiteSetting.s3_secret_access_key = "def"
|
||||
SiteSetting.enable_s3_inventory = true
|
||||
end
|
||||
|
||||
it "works" do
|
||||
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).once
|
||||
subject.execute({})
|
||||
end
|
||||
|
||||
it "doesn't execute when the site was restored within the last 48 hours" do
|
||||
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).never
|
||||
BackupMetadata.update_last_restore_date(47.hours.ago)
|
||||
|
||||
subject.execute({})
|
||||
end
|
||||
|
||||
it "executes when the site was restored more than 48 hours ago" do
|
||||
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).once
|
||||
BackupMetadata.update_last_restore_date(49.hours.ago)
|
||||
|
||||
subject.execute({})
|
||||
end
|
||||
end
|
||||
|
||||
context "S3 inventory disabled" do
|
||||
before { SiteSetting.enable_s3_inventory = false }
|
||||
|
||||
it "doesn't execute" do
|
||||
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).never
|
||||
subject.execute({})
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user