Commit a17b3d27 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Move prometheus service creation to the background job

Remove feature flag `projects_post_creation_worker`

Changelog: other
parent 8e35045d
......@@ -108,11 +108,7 @@ module Projects
current_user.invalidate_personal_projects_count
if Feature.enabled?(:projects_post_creation_worker, current_user, default_enabled: :yaml)
Projects::PostCreationWorker.perform_async(@project.id)
else
create_prometheus_integration
end
Projects::PostCreationWorker.perform_async(@project.id)
create_readme if @initialize_with_readme
end
......@@ -191,25 +187,6 @@ module Projects
@project
end
# Deprecated: https://gitlab.com/gitlab-org/gitlab/-/issues/326665
def create_prometheus_integration
integration = @project.find_or_initialize_integration(::Integrations::Prometheus.to_param)
# If the service has already been inserted in the database, that
# means it came from a template, and there's nothing more to do.
return if integration.persisted?
if integration.prometheus_available?
integration.save!
else
@project.prometheus_integration = nil
end
rescue ActiveRecord::RecordInvalid => e
Gitlab::ErrorTracking.track_exception(e, extra: { project_id: project.id })
@project.prometheus_integration = nil
end
def set_project_name_from_path
# if both name and path set - everything is ok
return if @project.name.present? && @project.path.present?
......
---
name: projects_post_creation_worker
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58119
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326665
milestone: '13.11'
type: development
group: group::source code
default_enabled: true
......@@ -705,69 +705,6 @@ RSpec.describe Projects::CreateService, '#execute' do
create_project(user, opts)
end
context 'when project has access to shared integration' do
before do
stub_feature_flags(projects_post_creation_worker: false)
end
context 'Prometheus integration is shared via group cluster' do
let(:cluster) { create(:cluster, :group, groups: [group]) }
let(:group) do
create(:group).tap do |group|
group.add_owner(user)
end
end
before do
create(:clusters_integrations_prometheus, cluster: cluster)
end
it 'creates Integrations::Prometheus record', :aggregate_failures do
project = create_project(user, opts.merge!(namespace_id: group.id))
integration = project.prometheus_integration
expect(integration.active).to be true
expect(integration.manual_configuration?).to be false
expect(integration.persisted?).to be true
end
end
context 'Prometheus integration is shared via instance cluster' do
let(:cluster) { create(:cluster, :instance) }
before do
create(:clusters_integrations_prometheus, cluster: cluster)
end
it 'creates Integrations::Prometheus record', :aggregate_failures do
project = create_project(user, opts)
integration = project.prometheus_integration
expect(integration.active).to be true
expect(integration.manual_configuration?).to be false
expect(integration.persisted?).to be true
end
it 'cleans invalid record and logs warning', :aggregate_failures do
invalid_integration_record = build(:prometheus_integration, properties: { api_url: nil, manual_configuration: true }.to_json)
allow(::Integrations::Prometheus).to receive(:new).and_return(invalid_integration_record)
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(an_instance_of(ActiveRecord::RecordInvalid), include(extra: { project_id: a_kind_of(Integer) }))
project = create_project(user, opts)
expect(project.prometheus_integration).to be_nil
end
end
context 'shared Prometheus integration is not available' do
it 'does not persist Integrations::Prometheus record' do
project = create_project(user, opts)
expect(project.prometheus_integration).to be_nil
end
end
end
context 'with external authorization enabled' do
before do
enable_external_authorization_service_check
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment