summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 21:07:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 21:07:59 +0000
commit1c25ac983cd1e4335faa1ec4922c314d6321e224 (patch)
tree68d88ab5d9ed5c3397e52fe85fc38ab237335a91 /app
parent83731155d997ae24c7e0cd5ffa6f0dba41bec6dc (diff)
downloadgitlab-ce-1c25ac983cd1e4335faa1ec4922c314d6321e224.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/clusters/applications/ingress.rb5
-rw-r--r--app/models/service.rb4
-rw-r--r--app/models/user_bot_type_enums.rb3
-rw-r--r--app/models/user_type_enums.rb3
-rw-r--r--app/services/merge_requests/after_create_service.rb19
-rw-r--r--app/services/merge_requests/create_service.rb21
-rw-r--r--app/workers/new_merge_request_worker.rb8
7 files changed, 36 insertions, 27 deletions
diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb
index 233920f4fe2..0158d909468 100644
--- a/app/models/clusters/applications/ingress.rb
+++ b/app/models/clusters/applications/ingress.rb
@@ -4,6 +4,7 @@ module Clusters
module Applications
class Ingress < ApplicationRecord
VERSION = '1.29.7'
+ INGRESS_CONTAINER_NAME = 'nginx-ingress-controller'
MODSECURITY_LOG_CONTAINER_NAME = 'modsecurity-log'
self.table_name = 'clusters_applications_ingress'
@@ -69,7 +70,7 @@ module Clusters
end
def ingress_service
- cluster.kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE)
+ cluster.kubeclient.get_service("ingress-#{INGRESS_CONTAINER_NAME}", Gitlab::Kubernetes::Helm::NAMESPACE)
end
private
@@ -123,7 +124,7 @@ module Clusters
{
"name" => "modsecurity-template-volume",
"configMap" => {
- "name" => "ingress-nginx-ingress-controller",
+ "name" => "ingress-#{INGRESS_CONTAINER_NAME}",
"items" => [
{
"key" => "modsecurity.conf",
diff --git a/app/models/service.rb b/app/models/service.rb
index e6b32db7eef..91597c51fca 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -319,10 +319,6 @@ class Service < ApplicationRecord
nil
end
- def self.find_by_template
- find_by(template: true)
- end
-
# override if needed
def supports_data_fields?
false
diff --git a/app/models/user_bot_type_enums.rb b/app/models/user_bot_type_enums.rb
index 9cfa73b15b2..1a9c02a3998 100644
--- a/app/models/user_bot_type_enums.rb
+++ b/app/models/user_bot_type_enums.rb
@@ -2,9 +2,6 @@
module UserBotTypeEnums
def self.bots
- # When adding a new key, please ensure you are not conflicting
- # with EE-only keys in app/models/user_type_enums.rb
- # or app/models/user_bot_type_enums.rb
{
alert_bot: 2
}
diff --git a/app/models/user_type_enums.rb b/app/models/user_type_enums.rb
index dfc908f5942..4e9dd70aee8 100644
--- a/app/models/user_type_enums.rb
+++ b/app/models/user_type_enums.rb
@@ -2,9 +2,6 @@
module UserTypeEnums
def self.types
- # When adding a new key, please ensure you are not conflicting
- # with EE-only keys in app/models/user_type_enums.rb
- # or app/models/user_bot_type_enums.rb
bots
end
diff --git a/app/services/merge_requests/after_create_service.rb b/app/services/merge_requests/after_create_service.rb
new file mode 100644
index 00000000000..6da30f8af16
--- /dev/null
+++ b/app/services/merge_requests/after_create_service.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module MergeRequests
+ class AfterCreateService < MergeRequests::BaseService
+ def execute(merge_request)
+ event_service.open_mr(merge_request, current_user)
+ notification_service.new_merge_request(merge_request, current_user)
+
+ # https://gitlab.com/gitlab-org/gitlab/issues/208813
+ if ::Feature.enabled?(:create_merge_request_pipelines_in_sidekiq, project)
+ create_pipeline_for(merge_request, current_user)
+ merge_request.update_head_pipeline
+ end
+
+ merge_request.diffs(include_stats: false).write_cache
+ merge_request.create_cross_references!(current_user)
+ end
+ end
+end
diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb
index 4a05d1fd7ef..d957a6425b2 100644
--- a/app/services/merge_requests/create_service.rb
+++ b/app/services/merge_requests/create_service.rb
@@ -13,19 +13,20 @@ module MergeRequests
create(merge_request)
end
- def before_create(merge_request)
- # current_user (defined in BaseService) is not available within run_after_commit block
- user = current_user
- merge_request.run_after_commit do
- NewMergeRequestWorker.perform_async(merge_request.id, user.id)
- end
- end
-
def after_create(issuable)
+ # Add new items to MergeRequests::AfterCreateService if they can
+ # be performed in Sidekiq
+ NewMergeRequestWorker.perform_async(issuable.id, current_user.id)
+
todo_service.new_merge_request(issuable, current_user)
issuable.cache_merge_request_closes_issues!(current_user)
- create_pipeline_for(issuable, current_user)
- issuable.update_head_pipeline
+
+ # https://gitlab.com/gitlab-org/gitlab/issues/208813
+ unless ::Feature.enabled?(:create_merge_request_pipelines_in_sidekiq, project)
+ create_pipeline_for(issuable, current_user)
+ issuable.update_head_pipeline
+ end
+
Gitlab::UsageDataCounters::MergeRequestCounter.count(:create)
link_lfs_objects(issuable)
diff --git a/app/workers/new_merge_request_worker.rb b/app/workers/new_merge_request_worker.rb
index 10a79841df9..f672d37a83e 100644
--- a/app/workers/new_merge_request_worker.rb
+++ b/app/workers/new_merge_request_worker.rb
@@ -12,11 +12,9 @@ class NewMergeRequestWorker # rubocop:disable Scalability/IdempotentWorker
def perform(merge_request_id, user_id)
return unless objects_found?(merge_request_id, user_id)
- EventCreateService.new.open_mr(issuable, user)
- NotificationService.new.new_merge_request(issuable, user)
-
- issuable.diffs(include_stats: false).write_cache
- issuable.create_cross_references!(user)
+ MergeRequests::AfterCreateService
+ .new(issuable.target_project, user)
+ .execute(issuable)
end
def issuable_class