[MM-53881] Make sure export filestore won't use bifrost (#24169)
Этот коммит содержится в:
@@ -125,10 +125,24 @@ func (settings *FileBackendSettings) CheckMandatoryS3Fields() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewFileBackend creates a new file backend
|
||||
func NewFileBackend(settings FileBackendSettings) (FileBackend, error) {
|
||||
return newFileBackend(settings, true)
|
||||
}
|
||||
|
||||
// NewExportFileBackend creates a new file backend for exports, that will not attempt to use bifrost.
|
||||
func NewExportFileBackend(settings FileBackendSettings) (FileBackend, error) {
|
||||
return newFileBackend(settings, false)
|
||||
}
|
||||
|
||||
func newFileBackend(settings FileBackendSettings, canBeCloud bool) (FileBackend, error) {
|
||||
switch settings.DriverName {
|
||||
case driverS3:
|
||||
backend, err := NewS3FileBackend(settings)
|
||||
newBackendFn := NewS3FileBackend
|
||||
if !canBeCloud {
|
||||
newBackendFn = NewS3FileBackendWithoutBifrost
|
||||
}
|
||||
backend, err := newBackendFn(settings)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unable to connect to the s3 backend")
|
||||
}
|
||||
|
||||
@@ -88,8 +88,17 @@ func (s *S3FileBackendNoBucketError) Error() string {
|
||||
return "no such bucket"
|
||||
}
|
||||
|
||||
// NewS3FileBackend returns an instance of an S3FileBackend.
|
||||
// NewS3FileBackend returns an instance of an S3FileBackend and determine if we are in Mattermost cloud or not.
|
||||
func NewS3FileBackend(settings FileBackendSettings) (*S3FileBackend, error) {
|
||||
return newS3FileBackend(settings, os.Getenv("MM_CLOUD_FILESTORE_BIFROST") != "")
|
||||
}
|
||||
|
||||
// NewS3FileBackendWithoutBifrost returns an instance of an S3FileBackend that will not use bifrost.
|
||||
func NewS3FileBackendWithoutBifrost(settings FileBackendSettings) (*S3FileBackend, error) {
|
||||
return newS3FileBackend(settings, false)
|
||||
}
|
||||
|
||||
func newS3FileBackend(settings FileBackendSettings, isCloud bool) (*S3FileBackend, error) {
|
||||
timeout := time.Duration(settings.AmazonS3RequestTimeoutMilliseconds) * time.Millisecond
|
||||
backend := &S3FileBackend{
|
||||
endpoint: settings.AmazonS3Endpoint,
|
||||
@@ -106,7 +115,6 @@ func NewS3FileBackend(settings FileBackendSettings) (*S3FileBackend, error) {
|
||||
timeout: timeout,
|
||||
presignExpires: time.Duration(settings.AmazonS3PresignExpiresSeconds) * time.Second,
|
||||
}
|
||||
isCloud := os.Getenv("MM_CLOUD_FILESTORE_BIFROST") != ""
|
||||
cli, err := backend.s3New(isCloud)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Ссылка в новой задаче
Block a user