Commit f2b54f75 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'sh-fix-consolidated-storage' into 'master'

Fix consolidated storage settings

See merge request gitlab-org/gitlab!53103
parents f399b96f e7d9434e
...@@ -124,9 +124,12 @@ class ObjectStoreSettings ...@@ -124,9 +124,12 @@ class ObjectStoreSettings
target_config = common_config.merge(overrides.slice(*ALLOWED_OBJECT_STORE_OVERRIDES)) target_config = common_config.merge(overrides.slice(*ALLOWED_OBJECT_STORE_OVERRIDES))
section = settings.try(store_type) section = settings.try(store_type)
next unless uses_object_storage?(section) # Admins can selectively disable object storage for a specific
# type as an override in the consolidated settings.
next unless overrides.fetch('enabled', true)
next unless section
if target_config['bucket'].blank? if section['enabled'] && target_config['bucket'].blank?
missing_bucket_for(store_type) missing_bucket_for(store_type)
next next
end end
...@@ -146,20 +149,6 @@ class ObjectStoreSettings ...@@ -146,20 +149,6 @@ class ObjectStoreSettings
private private
# Admins can selectively disable object storage for a specific type. If
# this hasn't been set, we assume that the consolidated settings
# should be used.
def uses_object_storage?(section)
# Use to_h to avoid https://gitlab.com/gitlab-org/gitlab/-/issues/286873
section = section.to_h
enabled_globally = section.fetch('enabled', false)
object_store_settings = section.fetch('object_store', {})
os_enabled = object_store_settings.fetch('enabled', true)
enabled_globally && os_enabled
end
# We only can use the common object storage settings if: # We only can use the common object storage settings if:
# 1. The common settings are defined # 1. The common settings are defined
# 2. The legacy settings are not defined # 2. The legacy settings are not defined
......
...@@ -130,13 +130,14 @@ RSpec.describe ObjectStoreSettings do ...@@ -130,13 +130,14 @@ RSpec.describe ObjectStoreSettings do
end end
end end
context 'when object storage is selectively disabled for artifacts' do context 'when object storage is disabled for artifacts with no bucket' do
before do before do
config['artifacts'] = { config['artifacts'] = {
'enabled' => true, 'enabled' => true,
'object_store' => { 'object_store' => {}
'enabled' => false }
} config['object_store']['objects']['artifacts'] = {
'enabled' => false
} }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment