Skip to content

Commit 3018043

Browse files
pfigelGargron
authored andcommitted
Add OpenStack Keystone V3 support (mastodon#4889)
Keystone V2 is deprecated in favour of V3. This adds the necessary connection parameters for establishing a V3 connection. Connections to V2 endpoints are still possible and the configuration should remain compatible. This also introduces a SWIFT_REGION variable for multi-region OpenStack environments and a SWIFT_CACHE_TTL that controls how long tokens and other meta-data is cached for. Caching tokens avoids rate-limiting errors that would result in media uploads becoming unavailable during high load or when using tasks like media:remove_remote. fog-openstack only supports token caching for V3 endpoints, so a recommendation for using V3 was added.
1 parent c2bee07 commit 3018043

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.env.production.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,19 @@ [email protected]
101101
# Swift (optional)
102102
# SWIFT_ENABLED=true
103103
# SWIFT_USERNAME=
104+
# For Keystone V3, the value for SWIFT_TENANT should be the project name
104105
# SWIFT_TENANT=
105106
# SWIFT_PASSWORD=
107+
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
108+
# issues with token rate-limiting during high load.
106109
# SWIFT_AUTH_URL=
107110
# SWIFT_CONTAINER=
108111
# SWIFT_OBJECT_URL=
112+
# SWIFT_REGION=
113+
# Defaults to 'default'
114+
# SWIFT_DOMAIN_NAME=
115+
# Defaults to 60 seconds. Set to 0 to disable
116+
# SWIFT_CACHE_TTL=
109117

110118
# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
111119
# S3_CLOUDFRONT_HOST=

config/initializers/paperclip.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@
4747
fog_credentials: {
4848
provider: 'OpenStack',
4949
openstack_username: ENV.fetch('SWIFT_USERNAME'),
50-
openstack_tenant: ENV.fetch('SWIFT_TENANT'),
50+
openstack_project_name: ENV.fetch('SWIFT_TENANT'),
5151
openstack_api_key: ENV.fetch('SWIFT_PASSWORD'),
5252
openstack_auth_url: ENV.fetch('SWIFT_AUTH_URL'),
53+
openstack_domain_name: ENV['SWIFT_DOMAIN_NAME'] || 'default',
54+
openstack_region: ENV['SWIFT_REGION'],
55+
openstack_cache_ttl: ENV['SWIFT_CACHE_TTL'] || 60,
5356
},
5457
fog_directory: ENV.fetch('SWIFT_CONTAINER'),
5558
fog_host: ENV.fetch('SWIFT_OBJECT_URL'),

0 commit comments

Comments
 (0)