mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 01:32:23 +08:00
FIX: S3 custom endpoint incompatible with dualstack (#29654)
Followup 0568d36133
S3 itself and other S3-compatible providers do not
allow using an S3 custom endpoint and dualstack at
the same time, so this commit fixes that by not using
dualstack when the endpoint is present.
This commit is contained in:
parent
64291fedf8
commit
97cf069a06
|
@ -169,7 +169,7 @@ class SiteSetting < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.use_dualstack_endpoint
|
def self.use_dualstack_endpoint
|
||||||
!SiteSetting.Upload.s3_region.start_with?("cn-")
|
SiteSetting.Upload.s3_endpoint.blank? && !SiteSetting.Upload.s3_region.start_with?("cn-")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enable_s3_uploads
|
def self.enable_s3_uploads
|
||||||
|
|
|
@ -196,4 +196,25 @@ RSpec.describe SiteSetting do
|
||||||
expect(SiteSetting.all_settings(filter_categories: ["required"]).count).to eq(12)
|
expect(SiteSetting.all_settings(filter_categories: ["required"]).count).to eq(12)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "Upload" do
|
||||||
|
before { setup_s3 }
|
||||||
|
|
||||||
|
describe "#use_dualstack_endpoint" do
|
||||||
|
it "returns false if s3_endpoint has been set" do
|
||||||
|
SiteSetting.s3_endpoint = "https://s3clone.test.com"
|
||||||
|
expect(SiteSetting.Upload.use_dualstack_endpoint).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false if the s3_region is in China" do
|
||||||
|
SiteSetting.s3_region = "cn-north-1"
|
||||||
|
expect(SiteSetting.Upload.use_dualstack_endpoint).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true if the s3_region is not in China" do
|
||||||
|
SiteSetting.s3_region = "us-west-1"
|
||||||
|
expect(SiteSetting.Upload.use_dualstack_endpoint).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -139,10 +139,6 @@ module SystemHelpers
|
||||||
SiteSetting.s3_secret_access_key = MinioRunner.config.minio_root_password
|
SiteSetting.s3_secret_access_key = MinioRunner.config.minio_root_password
|
||||||
SiteSetting.s3_endpoint = MinioRunner.config.minio_server_url
|
SiteSetting.s3_endpoint = MinioRunner.config.minio_server_url
|
||||||
|
|
||||||
# This is necessary for Minio because you cannot use dualstack
|
|
||||||
# at the same time as using a custom S3 endpoint.
|
|
||||||
SiteSetting.Upload.stubs(:use_dualstack_endpoint).returns(false)
|
|
||||||
|
|
||||||
SiteSetting.enable_direct_s3_uploads = enable_direct_s3_uploads
|
SiteSetting.enable_direct_s3_uploads = enable_direct_s3_uploads
|
||||||
SiteSetting.secure_uploads = enable_secure_uploads
|
SiteSetting.secure_uploads = enable_secure_uploads
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user