Commit 290974b4 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'ag-revert-vulnerability-export-replication' into 'master'

Remove Vulnerability::Exports replication

See merge request gitlab-org/gitlab!38295
parents fc2fbb31 2fc2f881
......@@ -26,7 +26,6 @@ ActiveSupport::Inflector.inflections do |inflect|
project_statistics
system_note_metadata
vulnerabilities_feedback
vulnerability_export_registry
vulnerability_feedback
)
inflect.acronym 'EE'
......
# frozen_string_literal: true
class Geo::VulnerabilityExportRegistry < Geo::BaseRegistry
include ::Geo::ReplicableRegistry
MODEL_CLASS = ::Vulnerabilities::Export
MODEL_FOREIGN_KEY = :vulnerability_export_id
belongs_to :vulnerability_export, class_name: 'Vulnerabilities::Export', foreign_key: :vulnerability_export_id
end
......@@ -2,25 +2,12 @@
module Vulnerabilities
class Export < ApplicationRecord
include ::Gitlab::Geo::ReplicableModel
self.table_name = "vulnerability_exports"
with_replicator Geo::VulnerabilityExportReplicator
belongs_to :project
belongs_to :group
belongs_to :author, optional: false, class_name: 'User'
has_one :vulnerability_export_verification_status, class_name: 'Vulnerabilities::ExportVerificationStatus', inverse_of: :vulnerability_export, foreign_key: :vulnerability_export_id
delegate :verification_retry_at, :verification_retry_at=,
:verified_at, :verified_at=,
:verification_checksum, :verification_checksum=,
:verification_failure, :verification_failure=,
:verification_retry_count, :verification_retry_count=,
to: :vulnerability_export_verification_status
mount_uploader :file, AttachmentUploader
after_save :update_file_store, if: :saved_change_to_file?
......@@ -96,18 +83,6 @@ module Vulnerabilities
self.update_column(:file_store, file.object_store)
end
def vulnerability_export_verification_status
super.presence || build_vulnerability_export_verification_status
end
def local?
file_store == ObjectStorage::Store::LOCAL
end
def self.replicables_for_geo_node
self.all
end
private
def make_project_level_export(project)
......
# frozen_string_literal: true
module Vulnerabilities
class ExportVerificationStatus < ApplicationRecord
self.primary_key = :vulnerability_export_id
self.table_name = 'vulnerability_export_verification_status'
belongs_to :vulnerability_export, class_name: 'Vulnerabilities::Export', inverse_of: :vulnerability_export_verification_status
end
end
# frozen_string_literal: true
module Geo
class VulnerabilityExportReplicator < Gitlab::Geo::Replicator
include ::Geo::BlobReplicatorStrategy
def self.model
::Vulnerabilities::Export
end
def carrierwave_uploader
model_record.file
end
def self.replication_enabled_by_default?
false
end
end
end
......@@ -22,8 +22,7 @@ module Geo
Geo::LfsObjectRegistry,
Geo::PackageFileRegistry,
Geo::ProjectRegistry,
Geo::UploadRegistry,
Geo::VulnerabilityExportRegistry
Geo::UploadRegistry
].freeze
BATCH_SIZE = 10000
......
......@@ -162,8 +162,7 @@ module Gitlab
# solutions can be found at
# https://gitlab.com/gitlab-org/gitlab/-/issues/227693
def self.replicator_classes
classes = [::Geo::PackageFileReplicator,
::Geo::VulnerabilityExportReplicator]
classes = [::Geo::PackageFileReplicator]
classes.select(&:enabled?)
end
......
# frozen_string_literal: true
FactoryBot.define do
factory :geo_vulnerability_export_registry, class: 'Geo::VulnerabilityExportRegistry' do
association :vulnerability_export, factory: :vulnerability_export
state { Geo::VulnerabilityExportRegistry.state_value(:pending) }
trait :synced do
state { Geo::VulnerabilityExportRegistry.state_value(:synced) }
last_synced_at { 5.days.ago }
end
trait :failed do
state { Geo::VulnerabilityExportRegistry.state_value(:failed) }
last_synced_at { 1.day.ago }
retry_count { 2 }
last_sync_failure { 'Random error' }
end
trait :started do
state { Geo::VulnerabilityExportRegistry.state_value(:started) }
last_synced_at { 1.day.ago }
retry_count { 0 }
end
end
end
......@@ -13,8 +13,6 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
describe '#replication_verification_complete?' do
before do
allow(Gitlab.config.geo.registry_replication).to receive(:enabled).and_return(true)
stub_feature_flags(geo_vulnerability_export_replication: false)
end
it 'prints messages for all verification checks' do
......
......@@ -346,11 +346,11 @@ RSpec.describe Gitlab::Geo, :geo, :request_store do
context 'when replication is disabled' do
before do
stub_feature_flags(geo_vulnerability_export_replication: false)
stub_feature_flags(geo_package_file_replication: false)
end
it 'does not return the corresponding replicator class' do
expect(described_class.replicator_classes).not_to include(Geo::VulnerabilityExportReplicator)
it 'does not return the replicator class' do
expect(described_class.replicator_classes).not_to include(Geo::PackageFileReplicator)
end
end
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::VulnerabilityExportRegistry, :geo, type: :model do
let_it_be(:registry) { create(:geo_vulnerability_export_registry) }
specify 'factory is valid' do
expect(registry).to be_valid
end
include_examples 'a Geo framework registry'
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::VulnerabilityExportReplicator do
let(:model_record) { build(:vulnerability_export, :with_csv_file) }
it_behaves_like 'a blob replicator'
end
......@@ -15,7 +15,6 @@ RSpec.describe Geo::RegistryConsistencyService, :geo, :use_clean_rails_memory_st
def model_class_factory_name(registry_class)
return :project_with_design if registry_class == ::Geo::DesignRegistry
return :package_file_with_file if registry_class == ::Geo::PackageFileRegistry
return :vulnerability_export if registry_class == ::Geo::VulnerabilityExportRegistry
registry_class::MODEL_CLASS.underscore.tr('/', '_').to_sym
end
......
......@@ -341,7 +341,6 @@ RSpec.describe 'geo rake tasks', :geo do
before do
stub_licensed_features(geo: true)
stub_current_geo_node(current_node)
stub_feature_flags(geo_vulnerability_export_replication: false)
allow(GeoNodeStatus).to receive(:current_node_status).and_return(geo_node_status)
allow(Gitlab.config.geo.registry_replication).to receive(:enabled).and_return(true)
......
......@@ -8,7 +8,6 @@ RSpec.describe 'gitlab:geo rake tasks', :geo do
before do
Rake.application.rake_require 'tasks/gitlab/geo'
stub_licensed_features(geo: true)
stub_feature_flags(geo_vulnerability_export_replication: false)
end
describe 'gitlab:geo:check_replication_verification_status' do
......
......@@ -84,7 +84,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
create(:design, project: project)
upload = create(:upload)
package_file = create(:conan_package_file, :conan_package)
vulnerability_export = create(:vulnerability_export, :with_csv_file)
container_repository = create(:container_repository, project: project)
expect(Geo::LfsObjectRegistry.where(lfs_object_id: lfs_object.id).count).to eq(0)
......@@ -93,7 +92,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
expect(Geo::DesignRegistry.where(project_id: project.id).count).to eq(0)
expect(Geo::UploadRegistry.where(file_id: upload.id).count).to eq(0)
expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(0)
expect(Geo::VulnerabilityExportRegistry.where(vulnerability_export_id: vulnerability_export.id).count).to eq(0)
expect(Geo::ContainerRepositoryRegistry.where(container_repository_id: container_repository.id).count).to eq(0)
subject.perform
......@@ -104,7 +102,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
expect(Geo::DesignRegistry.where(project_id: project.id).count).to eq(1)
expect(Geo::UploadRegistry.where(file_id: upload.id).count).to eq(1)
expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(1)
expect(Geo::VulnerabilityExportRegistry.where(vulnerability_export_id: vulnerability_export.id).count).to eq(1)
expect(Geo::ContainerRepositoryRegistry.where(container_repository_id: container_repository.id).count).to eq(1)
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