Skip to content
Browse files

FEATURE: Add SiteSetting for s3_configure_tombstone_policy

Add SiteSetting for s3_configure_tombstone_policy, skip policy generation if turned off (default on)
  • Loading branch information
rishabhnambiar authored and SamSaffron committed Sep 17, 2018
1 parent 725d2c0 commit 4f46aa1ba33a47e97add70f863c6aac9b55df531
Showing with 25 additions and 11 deletions.
  1. +1 −0 config/locales/server.en.yml
  2. +3 −0 config/site_settings.yml
  3. +1 −0 lib/s3_helper.rb
  4. +20 −11 spec/components/s3_helper_spec.rb
@@ -1350,6 +1350,7 @@ en:
s3_backup_bucket: "The remote bucket to hold backups. WARNING: Make sure it is a private bucket."
s3_endpoint: "The endpoint can be modified to backup to an S3 compatible service like DigitalOcean Spaces or Minio. WARNING: Use default if using AWS S3"
s3_force_path_style: "Enforce path-style addressing for your custom endpoint. IMPORTANT: Required for using Minio uploads and backups."
s3_configure_tombstone_policy: "Enable automatic deletion policy for tombstone uploads. IMPORTANT: If disabled, no space will be reclaimed after uploads are deleted."
s3_disable_cleanup: "Disable the removal of backups from S3 when removed locally."
backup_time_of_day: "Time of day UTC when the backup should occur."
backup_with_uploads: "Include uploads in scheduled backups. Disabling this will only backup the database."
@@ -964,6 +964,9 @@ files:
regex: '^https?:\/\/.+[^\/]$'
default: false
default: true
shadowed_by_global: true
client: true
default: true
@@ -131,6 +131,7 @@ def update_lifecycle(id, days, prefix: nil, tag: nil)

def update_tombstone_lifecycle(grace_period)
return if !SiteSetting.s3_configure_tombstone_policy
return if @tombstone_prefix.blank?
update_lifecycle("purge_tombstone", grace_period, prefix: @tombstone_prefix)
@@ -2,13 +2,12 @@
require "rails_helper"

describe "S3Helper" do
before(:each) do
SiteSetting.enable_s3_uploads = true
SiteSetting.s3_access_key_id = "abc"
SiteSetting.s3_secret_access_key = "def"

it "can correctly set the purge policy" do

stub_request(:get, "").
to_return(status: 404, body: "", headers: {})

lifecycle = <<~XML
@lifecycle = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration xmlns="">
@@ -29,9 +28,16 @@

it "can correctly set the purge policy" do
SiteSetting.s3_configure_tombstone_policy = true

stub_request(:get, "").
to_return(status: 404, body: "", headers: {})

stub_request(:get, "").
to_return(status: 200, body: lifecycle, headers: {})
to_return(status: 200, body: @lifecycle, headers: {})

stub_request(:put, "").
with do |req|
@@ -40,14 +46,17 @@
rules = hash["LifecycleConfiguration"]["Rule"]

expect(rules.length).to eq(2)

expect(rules[1]["Expiration"]["Days"]).to eq("100")
# fixes the bad filter
expect(rules[0]["Filter"]["Prefix"]).to eq("projectdocs/")
end.to_return(status: 200, body: "", headers: {})

SiteSetting.enable_s3_uploads = true
SiteSetting.s3_access_key_id = "abc"
SiteSetting.s3_secret_access_key = "def"
helper ='bob', 'tomb')

it "can skip policy update when s3_configure_tombstone_policy is false" do
SiteSetting.s3_configure_tombstone_policy = false

helper ='bob', 'tomb')

1 comment on commit 4f46aa1


This comment has been minimized.

Copy link

discoursebot commented on 4f46aa1 Mar 15, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Please sign in to comment.
You can’t perform that action at this time.