summaryrefslogtreecommitdiff
path: root/config/initializers/6_validations.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2017-05-17 18:17:15 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-08-04 15:38:48 +0200
commit3598e60bf20b185b3f8d4e9a88a8eff39c8f729b (patch)
treeba84a7e7972d4a2563bb79485933fb78462868de /config/initializers/6_validations.rb
parent990feb9f2b886c5bd0ac37339f149b8e80202019 (diff)
downloadgitlab-ce-3598e60bf20b185b3f8d4e9a88a8eff39c8f729b.tar.gz
Add a Circuitbreaker for storage paths
Diffstat (limited to 'config/initializers/6_validations.rb')
-rw-r--r--config/initializers/6_validations.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/config/initializers/6_validations.rb b/config/initializers/6_validations.rb
index 9e24f42d284..92ce4dd03cd 100644
--- a/config/initializers/6_validations.rb
+++ b/config/initializers/6_validations.rb
@@ -7,6 +7,13 @@ def find_parent_path(name, path)
Gitlab.config.repositories.storages.detect do |n, rs|
name != n && Pathname.new(rs['path']).realpath == parent
end
+rescue Errno::EIO, Errno::ENOENT => e
+ warning = "WARNING: couldn't verify #{path} (#{name}). "\
+ "If this is an external storage, it might be offline."
+ message = "#{warning}\n#{e.message}"
+ Rails.logger.error("#{message}\n\t" + e.backtrace.join("\n\t"))
+
+ nil
end
def storage_validation_error(message)
@@ -29,6 +36,15 @@ def validate_storages_config
if !repository_storage.is_a?(Hash) || repository_storage['path'].nil?
storage_validation_error("#{name} is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example")
end
+
+ %w(failure_count_threshold failure_wait_time failure_reset_time storage_timeout).each do |setting|
+ # Falling back to the defaults is fine!
+ next if repository_storage[setting].nil?
+
+ unless repository_storage[setting].to_f > 0
+ storage_validation_error("#{setting}, for storage `#{name}` needs to be greater than 0")
+ end
+ end
end
end