diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-03 12:16:45 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-04 15:38:49 +0200 |
commit | 3899d07f9eb5ffa2369195c800be18e297f67613 (patch) | |
tree | 5a8e252d127878f4057ec884f3407874b86645d4 | |
parent | 0fa94a0dddfc38635abf49a38dbadc9b9ead4d7a (diff) | |
download | gitlab-ce-3899d07f9eb5ffa2369195c800be18e297f67613.tar.gz |
Move hostname to Gitlab::Environment
-rw-r--r-- | config/initializers/1_settings.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/environment.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/git/storage/circuit_breaker.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_health_check_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/git/storage/circuit_breaker_spec.rb | 2 |
5 files changed, 10 insertions, 4 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 017537f30be..7a43bf939ea 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -222,7 +222,6 @@ Settings.gitlab['default_branch_protection'] ||= 2 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil? Settings.gitlab['host'] ||= ENV['GITLAB_HOST'] || 'localhost' Settings.gitlab['ssh_host'] ||= Settings.gitlab.host -Settings.gitlab['hostname'] ||= ENV['HOSTNAME'] || Socket.gethostname Settings.gitlab['https'] = false if Settings.gitlab['https'].nil? Settings.gitlab['port'] ||= ENV['GITLAB_PORT'] || (Settings.gitlab.https ? 443 : 80) Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' diff --git a/lib/gitlab/environment.rb b/lib/gitlab/environment.rb new file mode 100644 index 00000000000..5e0dd6e7859 --- /dev/null +++ b/lib/gitlab/environment.rb @@ -0,0 +1,7 @@ +module Gitlab + module Environment + def self.hostname + @hostname ||= ENV['HOSTNAME'] || Socket.gethostname + end + end +end diff --git a/lib/gitlab/git/storage/circuit_breaker.rb b/lib/gitlab/git/storage/circuit_breaker.rb index c722771e0d5..7b040a05c42 100644 --- a/lib/gitlab/git/storage/circuit_breaker.rb +++ b/lib/gitlab/git/storage/circuit_breaker.rb @@ -31,7 +31,7 @@ module Gitlab cached_circuitbreakers[storage] end - def initialize(storage, hostname = Gitlab.config.gitlab.hostname) + def initialize(storage, hostname = Gitlab::Environment.hostname) @storage = storage @hostname = hostname diff --git a/spec/features/admin/admin_health_check_spec.rb b/spec/features/admin/admin_health_check_spec.rb index 634dfd53f71..37fd3e171eb 100644 --- a/spec/features/admin/admin_health_check_spec.rb +++ b/spec/features/admin/admin_health_check_spec.rb @@ -64,7 +64,7 @@ feature "Admin Health Check", feature: true, broken_storage: true do end it 'shows storage failure information' do - hostname = Gitlab.config.gitlab.hostname + hostname = Gitlab::Environment.hostname expect(page).to have_content('broken: failed storage access attempt on host:') expect(page).to have_content("#{hostname}: 1 of 10 failures.") diff --git a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb index 479e53230bc..6fab224ad0d 100644 --- a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb +++ b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: true, broken_storage: true do let(:circuit_breaker) { described_class.new('default') } - let(:hostname) { Gitlab.config.gitlab.hostname } + let(:hostname) { Gitlab::Environment.hostname } let(:cache_key) { "storage_accessible:default:#{hostname}" } def value_from_redis(name) |