Commit 6a63d330 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '336511-feature-flag-cleanup' into 'master'

Remove the feature flag packages_nuget_new_package_file_updater

See merge request gitlab-org/gitlab!69755
parents 7a9c2762 1630d748
...@@ -21,11 +21,7 @@ module Packages ...@@ -21,11 +21,7 @@ module Packages
try_obtain_lease do try_obtain_lease do
@package_file.transaction do @package_file.transaction do
if use_new_package_file_updater? process_package_update
new_execute
else
legacy_execute
end
end end
end end
rescue ActiveRecord::RecordInvalid => e rescue ActiveRecord::RecordInvalid => e
...@@ -34,7 +30,7 @@ module Packages ...@@ -34,7 +30,7 @@ module Packages
private private
def new_execute def process_package_update
package_to_destroy = nil package_to_destroy = nil
target_package = @package_file.package target_package = @package_file.package
...@@ -50,36 +46,11 @@ module Packages ...@@ -50,36 +46,11 @@ module Packages
end end
update_package(target_package) update_package(target_package)
::Packages::UpdatePackageFileService.new(@package_file, package_id: target_package.id, file_name: package_filename) ::Packages::UpdatePackageFileService.new(@package_file, package_id: target_package.id, file_name: package_filename)
.execute .execute
package_to_destroy&.destroy! package_to_destroy&.destroy!
end end
def legacy_execute
if existing_package
package = link_to_existing_package
elsif symbol_package?
raise InvalidMetadataError, 'symbol package is invalid, matching package does not exist'
else
package = update_linked_package
end
update_package(package)
# Updating file_name updates the path where the file is stored.
# We must pass the file again so that CarrierWave can handle the update
@package_file.update!(
file_name: package_filename,
file: @package_file.file
)
end
def use_new_package_file_updater?
::Feature.enabled?(:packages_nuget_new_package_file_updater, @package_file.project, default_enabled: :yaml)
end
def update_package(package) def update_package(package)
return if symbol_package? return if symbol_package?
......
---
name: packages_nuget_new_package_file_updater
introduced_by_url:
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/336511
milestone: '14.2'
type: development
group: group::package
default_enabled: true
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_shared_state do RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
let(:package) { create(:nuget_package, :processing, :with_symbol_package) } let!(:package) { create(:nuget_package, :processing, :with_symbol_package) }
let(:package_file) { package.package_files.first } let(:package_file) { package.package_files.first }
let(:service) { described_class.new(package_file) } let(:service) { described_class.new(package_file) }
let(:package_name) { 'DummyProject.DummyPackage' } let(:package_name) { 'DummyProject.DummyPackage' }
...@@ -63,7 +63,6 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_ ...@@ -63,7 +63,6 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_
end end
end end
shared_examples 'handling all conditions' do
context 'with no existing package' do context 'with no existing package' do
let(:package_id) { package.id } let(:package_id) { package.id }
...@@ -273,24 +272,4 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_ ...@@ -273,24 +272,4 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_
end end
end end
end end
context 'with packages_nuget_new_package_file_updater enabled' do
before do
expect(service).not_to receive(:legacy_execute)
end
it_behaves_like 'handling all conditions'
end
context 'with packages_nuget_new_package_file_updater disabled' do
before do
stub_feature_flags(packages_nuget_new_package_file_updater: false)
expect(::Packages::UpdatePackageFileService)
.not_to receive(:new).with(package_file, instance_of(Hash)).and_call_original
expect(service).not_to receive(:new_execute)
end
it_behaves_like 'handling all conditions'
end
end
end end
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