diff options
| author | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-07 14:56:15 +0000 |
|---|---|---|
| committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-07 14:56:15 +0000 |
| commit | 5bf65c9306960cdbe9b64bf8f62dc909d1cc6440 (patch) | |
| tree | 22a4b3a199fae27c64e849c6f8c805c2b5008e5c /config/initializers | |
| parent | fa716921b8b136f5d4b09de9723568d5ac101f84 (diff) | |
| parent | fda83a6179ae63f094410942e95951b40c3ad24b (diff) | |
| download | gitlab-ce-5bf65c9306960cdbe9b64bf8f62dc909d1cc6440.tar.gz | |
Merge branch 'bvl-nfs-circuitbreaker' into 'master'
Circuitbreaker for storage paths
Closes #32207, #33117, gitlab-com/infrastructure#1946, and gitlab-com/infrastructure#1775
See merge request !11449
Diffstat (limited to 'config/initializers')
| -rw-r--r-- | config/initializers/1_settings.rb | 11 | ||||
| -rw-r--r-- | config/initializers/6_validations.rb | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 63f4c8c9e0a..7a43bf939ea 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -433,6 +433,17 @@ end Settings.repositories.storages.values.each do |storage| # Expand relative paths storage['path'] = Settings.absolute(storage['path']) + # Set failure defaults + storage['failure_count_threshold'] ||= 10 + storage['failure_wait_time'] ||= 30 + storage['failure_reset_time'] ||= 1800 + storage['storage_timeout'] ||= 5 + # Set turn strings into numbers + storage['failure_count_threshold'] = storage['failure_count_threshold'].to_i + storage['failure_wait_time'] = storage['failure_wait_time'].to_i + storage['failure_reset_time'] = storage['failure_reset_time'].to_i + # We might want to have a timeout shorter than 1 second. + storage['storage_timeout'] = storage['storage_timeout'].to_f end # 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 |
