Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 21:05:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 21:05:56 +0300
commit40597fdec080d55d36e97aab1a0b98dfc35517b9 (patch)
tree20cb97ab39cd511c22657cc23c5834464001feac
parenta712542edb9d52105409462de3e56d2a6d6f6c7a (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.dockerignore1
-rw-r--r--changelogs/unreleased/32899-handle-race-condition-for-container-registry-sync.yml5
-rw-r--r--com/lib/com/gitlab/patch/draw_route.rb16
-rw-r--r--com/spec/lib/gitlab/patch/draw_route_spec.rb25
-rw-r--r--config/application.rb10
-rw-r--r--config/initializers/0_inject_com_module.rb26
-rw-r--r--config/light_settings.rb32
-rw-r--r--lib/gitlab.rb13
-rw-r--r--lib/gitlab/patch/draw_route.rb7
-rw-r--r--qa/Dockerfile2
-rw-r--r--spec/com_spec_helper.rb3
-rw-r--r--spec/fast_spec_helper.rb2
-rw-r--r--spec/lib/gitlab_spec.rb12
13 files changed, 17 insertions, 137 deletions
diff --git a/.dockerignore b/.dockerignore
index 2d1af2c25fc..d5568619169 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -3,7 +3,6 @@
# Ignore all folders except qa/, config/initializers and the root of lib/ since
# the files we need to build the QA image are in these folders.
# Following are the files we need:
-# - ./config/light_settings.rb
# - ./config/initializers/0_inject_enterprise_edition_module.rb
# - ./ee/app/models/license.rb
# - ./lib/gitlab.rb
diff --git a/changelogs/unreleased/32899-handle-race-condition-for-container-registry-sync.yml b/changelogs/unreleased/32899-handle-race-condition-for-container-registry-sync.yml
new file mode 100644
index 00000000000..4182f49b730
--- /dev/null
+++ b/changelogs/unreleased/32899-handle-race-condition-for-container-registry-sync.yml
@@ -0,0 +1,5 @@
+---
+title: 'Geo: Fix race condition for container synchronization'
+merge_request: 17823
+author:
+type: fixed
diff --git a/com/lib/com/gitlab/patch/draw_route.rb b/com/lib/com/gitlab/patch/draw_route.rb
deleted file mode 100644
index 8626ff06c28..00000000000
--- a/com/lib/com/gitlab/patch/draw_route.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-module Com
- module Gitlab
- module Patch
- module DrawRoute
- extend ::Gitlab::Utils::Override
-
- override :draw_com
- def draw_com(routes_name)
- draw_route(route_path("com/config/routes/#{routes_name}.rb"))
- end
- end
- end
- end
-end
diff --git a/com/spec/lib/gitlab/patch/draw_route_spec.rb b/com/spec/lib/gitlab/patch/draw_route_spec.rb
deleted file mode 100644
index 823bebd5c0d..00000000000
--- a/com/spec/lib/gitlab/patch/draw_route_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require 'fast_spec_helper'
-require 'com_spec_helper'
-
-describe Gitlab::Patch::DrawRoute do
- subject do
- Class.new do
- include Gitlab::Patch::DrawRoute
-
- def route_path(route_name)
- File.expand_path("../../../../../#{route_name}", __dir__)
- end
- end.new
- end
-
- before do
- allow(subject).to receive(:instance_eval)
- end
-
- it 'raises an error when nothing is drawn' do
- expect { subject.draw(:non_existing) }
- .to raise_error(described_class::RoutesNotFound)
- end
-end
diff --git a/config/application.rb b/config/application.rb
index 192e836594a..5d7c52c5d81 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -22,7 +22,6 @@ module Gitlab
require_dependency Rails.root.join('lib/gitlab/current_settings')
require_dependency Rails.root.join('lib/gitlab/middleware/read_only')
require_dependency Rails.root.join('lib/gitlab/middleware/basic_health_check')
- require_dependency Rails.root.join('config/light_settings')
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@@ -63,15 +62,6 @@ module Gitlab
config.paths['app/views'].unshift "#{config.root}/ee/app/views"
end
- if LightSettings.com?
- com_paths = config.eager_load_paths.each_with_object([]) do |path, memo|
- com_path = config.root.join('com', Pathname.new(path).relative_path_from(config.root))
- memo << com_path.to_s
- end
-
- config.eager_load_paths.push(*com_paths)
- end
-
# Rake tasks ignore the eager loading settings, so we need to set the
# autoload paths explicitly
config.autoload_paths = config.eager_load_paths.dup
diff --git a/config/initializers/0_inject_com_module.rb b/config/initializers/0_inject_com_module.rb
deleted file mode 100644
index 9802eb37ec3..00000000000
--- a/config/initializers/0_inject_com_module.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-require 'active_support/inflector'
-
-module InjectComModule
- def prepend_if_com(constant, with_descendants: false)
- return unless Gitlab.com?
-
- com_module = constant.constantize
- prepend(com_module)
-
- if with_descendants
- descendants.each { |descendant| descendant.prepend(com_module) }
- end
- end
-
- def extend_if_com(constant)
- extend(constant.constantize) if Gitlab.com?
- end
-
- def include_if_com(constant)
- include(constant.constantize) if Gitlab.com?
- end
-end
-
-Module.prepend(InjectComModule)
diff --git a/config/light_settings.rb b/config/light_settings.rb
deleted file mode 100644
index 19343ba7de0..00000000000
--- a/config/light_settings.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-class LightSettings
- GL_HOST ||= 'gitlab.com'
- GL_SUBDOMAIN_REGEX ||= %r{\A[a-z0-9]+\.gitlab\.com\z}.freeze
-
- class << self
- def com?
- return Thread.current[:is_com] unless Thread.current[:is_com].nil?
-
- Thread.current[:is_com] = host == GL_HOST || gl_subdomain?
- end
-
- private
-
- def config
- YAML.safe_load(File.read(settings_path), aliases: true)[Rails.env]
- end
-
- def settings_path
- Rails.root.join('config', 'gitlab.yml')
- end
-
- def host
- config.dig('gitlab', 'host') || ENV['GITLAB_HOST'] || 'localhost'
- end
-
- def gl_subdomain?
- GL_SUBDOMAIN_REGEX === host
- end
- end
-end
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index 43b3642fd6b..b337f5cbf2c 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'pathname'
-require_relative '../config/light_settings'
module Gitlab
def self.root
@@ -38,18 +37,24 @@ module Gitlab
COM_URL = 'https://gitlab.com'
APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))}.freeze
+ SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z}.freeze
VERSION = File.read(root.join("VERSION")).strip.freeze
INSTALLATION_TYPE = File.read(root.join("INSTALLATION_TYPE")).strip.freeze
HTTP_PROXY_ENV_VARS = %w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY).freeze
def self.com?
- LightSettings.com?
+ # Check `gl_subdomain?` as well to keep parity with gitlab.com
+ Gitlab.config.gitlab.url == COM_URL || gl_subdomain?
end
def self.org?
Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
end
+ def self.gl_subdomain?
+ SUBDOMAIN_REGEX === Gitlab.config.gitlab.url
+ end
+
def self.dev_env_org_or_com?
dev_env_or_com? || org?
end
@@ -74,10 +79,6 @@ module Gitlab
yield if ee?
end
- def self.com
- yield if com?
- end
-
def self.http_proxy_env?
HTTP_PROXY_ENV_VARS.any? { |name| ENV[name] }
end
diff --git a/lib/gitlab/patch/draw_route.rb b/lib/gitlab/patch/draw_route.rb
index fc9d7ae805f..4c8ca015974 100644
--- a/lib/gitlab/patch/draw_route.rb
+++ b/lib/gitlab/patch/draw_route.rb
@@ -6,12 +6,11 @@ module Gitlab
module Patch
module DrawRoute
prepend_if_ee('EE::Gitlab::Patch::DrawRoute') # rubocop: disable Cop/InjectEnterpriseEditionModule
- prepend_if_com('Com::Gitlab::Patch::DrawRoute')
RoutesNotFound = Class.new(StandardError)
def draw(routes_name)
- drawn_any = draw_ce(routes_name) | draw_ee(routes_name) | draw_com(routes_name)
+ drawn_any = draw_ce(routes_name) | draw_ee(routes_name)
drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}"))
end
@@ -24,10 +23,6 @@ module Gitlab
true
end
- def draw_com(_)
- false
- end
-
def route_path(routes_name)
Rails.root.join(routes_name)
end
diff --git a/qa/Dockerfile b/qa/Dockerfile
index 97c2cd482f5..e695ab82969 100644
--- a/qa/Dockerfile
+++ b/qa/Dockerfile
@@ -49,12 +49,10 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
WORKDIR /home/gitlab/qa
COPY ./qa/Gemfile* /home/gitlab/qa/
-COPY ./config/light_settings.rb /home/gitlab/config/light_settings.rb
COPY ./config/initializers/0_inject_enterprise_edition_module.rb /home/gitlab/config/initializers/
# Copy VERSION to ensure the COPY succeeds to copy at least one file since ee/app/models/license.rb isn't present in FOSS
# The [b] part makes ./ee/app/models/license.r[b] a pattern that is allowed to return no files (which is the case in FOSS)
COPY VERSION ./ee/app/models/license.r[b] /home/gitlab/ee/app/models/
-COPY ./config/light_settings.rb /home/gitlab/config/
COPY ./lib/gitlab.rb /home/gitlab/lib/
COPY ./INSTALLATION_TYPE ./VERSION /home/gitlab/
RUN cd /home/gitlab/qa/ && bundle install --jobs=$(nproc) --retry=3 --quiet
diff --git a/spec/com_spec_helper.rb b/spec/com_spec_helper.rb
deleted file mode 100644
index f71ccde9509..00000000000
--- a/spec/com_spec_helper.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-Settings.gitlab[:url] = "https://test.gitlab.com"
diff --git a/spec/fast_spec_helper.rb b/spec/fast_spec_helper.rb
index 3fe3f9ff9a9..1a8af335244 100644
--- a/spec/fast_spec_helper.rb
+++ b/spec/fast_spec_helper.rb
@@ -7,12 +7,10 @@ ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true'
require 'active_support/dependencies'
require_relative '../config/initializers/0_inject_enterprise_edition_module'
-require_relative '../config/initializers/0_inject_com_module'
require_relative '../config/settings'
require_relative 'support/rspec'
require 'active_support/all'
ActiveSupport::Dependencies.autoload_paths << 'lib'
ActiveSupport::Dependencies.autoload_paths << 'ee/lib'
-ActiveSupport::Dependencies.autoload_paths << 'com/lib'
ActiveSupport::XmlMini.backend = 'Nokogiri'
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index bb4f71982a0..c1d171815ba 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -71,30 +71,26 @@ describe Gitlab do
end
describe '.com?' do
- before do
- Thread.current[:is_com] = nil
- end
-
it 'is true when on GitLab.com' do
- allow(LightSettings).to receive(:host).and_return('gitlab.com')
+ stub_config_setting(url: 'https://gitlab.com')
expect(described_class.com?).to eq true
end
it 'is true when on staging' do
- allow(LightSettings).to receive(:host).and_return('staging.gitlab.com')
+ stub_config_setting(url: 'https://staging.gitlab.com')
expect(described_class.com?).to eq true
end
it 'is true when on other gitlab subdomain' do
- allow(LightSettings).to receive(:host).and_return('example.gitlab.com')
+ stub_config_setting(url: 'https://example.gitlab.com')
expect(described_class.com?).to eq true
end
it 'is false when not on GitLab.com' do
- allow(LightSettings).to receive(:host).and_return('example.com')
+ stub_config_setting(url: 'http://example.com')
expect(described_class.com?).to eq false
end