summaryrefslogtreecommitdiff
path: root/config/object_store_settings.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /config/object_store_settings.rb
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'config/object_store_settings.rb')
-rw-r--r--config/object_store_settings.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/config/object_store_settings.rb b/config/object_store_settings.rb
index ec433c4dda6..9f5323426d9 100644
--- a/config/object_store_settings.rb
+++ b/config/object_store_settings.rb
@@ -3,6 +3,13 @@ class ObjectStoreSettings
SUPPORTED_TYPES = %w(artifacts external_diffs lfs uploads packages dependency_proxy terraform_state pages).freeze
ALLOWED_OBJECT_STORE_OVERRIDES = %w(bucket enabled proxy_download).freeze
+ # To ensure the one Workhorse credential matches the Rails config, we
+ # enforce consolidated settings on those accelerated
+ # endpoints. Technically dependency_proxy and terraform_state fall
+ # into this category, but they will likely be handled by Workhorse in
+ # the future.
+ WORKHORSE_ACCELERATED_TYPES = SUPPORTED_TYPES - %w(pages)
+
# pages may be enabled but use legacy disk storage
# we don't need to raise an error in that case
ALLOWED_INCOMPLETE_TYPES = %w(pages).freeze
@@ -124,6 +131,10 @@ class ObjectStoreSettings
next
end
+ # If a storage type such as Pages defines its own connection and does not
+ # use Workhorse acceleration, we allow it to override the consolidated form.
+ next if allowed_storage_specific_settings?(store_type, section.to_h)
+
# Map bucket (external name) -> remote_directory (internal representation)
target_config['remote_directory'] = target_config.delete('bucket')
target_config['consolidated_settings'] = true
@@ -140,7 +151,7 @@ class ObjectStoreSettings
return false unless settings.dig('object_store', 'enabled')
return false unless settings.dig('object_store', 'connection').present?
- SUPPORTED_TYPES.each do |store|
+ WORKHORSE_ACCELERATED_TYPES.each do |store|
# to_h is needed because something strange happens to
# Settingslogic#dig when stub_storage_settings is run in tests:
#
@@ -169,4 +180,15 @@ class ObjectStoreSettings
raise message
end
end
+
+ def allowed_storage_specific_settings?(store_type, section)
+ return false if WORKHORSE_ACCELERATED_TYPES.include?(store_type)
+
+ has_object_store_configured?(section)
+ end
+
+ def has_object_store_configured?(section)
+ # Omnibus defaults to an empty hash for connection
+ section.dig('object_store', 'enabled') && section.dig('object_store', 'connection').present?
+ end
end