Commit f8ed0657 authored by Alex Ives's avatar Alex Ives Committed by Douglas Barbosa Alexandre

Remove non versioned terraform state replication

Non-versioned terraform states are being migrated to versioned
and we never launched the replication for non-versioned ones so
this code can be removed

- Remove terraform_state_registry from the tracking database
- Remove indexes for verification information from the terraform
  state table
- Ignore verification columns in the terraform state table

Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/255951
parent e6f4b76f
......@@ -4,6 +4,12 @@ module Terraform
class State < ApplicationRecord
include UsageStatistics
include FileStoreMounter
include IgnorableColumns
# These columns are being removed since geo replication falls to the versioned state
# Tracking in https://gitlab.com/gitlab-org/gitlab/-/issues/258262
ignore_columns %i[verification_failure verification_retry_at verified_at verification_retry_count verification_checksum],
remove_with: '13.7',
remove_after: '2020-12-22'
HEX_REGEXP = %r{\A\h+\z}.freeze
UUID_LENGTH = 32
......@@ -34,10 +40,6 @@ module Terraform
versioning_enabled ? latest_version&.file : file
end
def local?
file_store == ObjectStorage::Store::LOCAL
end
def locked?
self.lock_xid.present?
end
......@@ -54,5 +56,3 @@ module Terraform
end
end
end
Terraform::State.prepend_if_ee('EE::Terraform::State')
......@@ -26,7 +26,6 @@ ActiveSupport::Inflector.inflections do |inflect|
project_statistics
snippet_repository_registry
system_note_metadata
terraform_state_registry
terraform_state_version_registry
vulnerabilities_feedback
vulnerability_feedback
......
# frozen_string_literal: true
class RemoveTerraformStateVerificationIndexes < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
CHECKSUM_INDEX_NAME = "terraform_states_verification_checksum_partial".freeze
FAILURE_INDEX_NAME = "terraform_states_verification_failure_partial".freeze
disable_ddl_transaction!
def up
remove_concurrent_index :terraform_states, :verification_failure, name: FAILURE_INDEX_NAME
remove_concurrent_index :terraform_states, :verification_checksum, name: CHECKSUM_INDEX_NAME
end
def down
add_concurrent_index :terraform_states, :verification_failure, where: "(verification_failure IS NOT NULL)", name: FAILURE_INDEX_NAME
add_concurrent_index :terraform_states, :verification_checksum, where: "(verification_checksum IS NOT NULL)", name: CHECKSUM_INDEX_NAME
end
end
c390843c8a93ca429d1442d7b54f5f9dc01e0343c71ed1a046f11968cc10810d
\ No newline at end of file
......@@ -21656,10 +21656,6 @@ CREATE INDEX terraform_state_versions_verification_checksum_partial ON terraform
CREATE INDEX terraform_state_versions_verification_failure_partial ON terraform_state_versions USING btree (verification_failure) WHERE (verification_failure IS NOT NULL);
CREATE INDEX terraform_states_verification_checksum_partial ON terraform_states USING btree (verification_checksum) WHERE (verification_checksum IS NOT NULL);
CREATE INDEX terraform_states_verification_failure_partial ON terraform_states USING btree (verification_failure) WHERE (verification_failure IS NOT NULL);
CREATE INDEX tmp_build_stage_position_index ON ci_builds USING btree (stage_id, stage_idx) WHERE (stage_idx IS NOT NULL);
CREATE INDEX tmp_index_for_email_unconfirmation_migration ON emails USING btree (id) WHERE (confirmed_at IS NOT NULL);
......
......@@ -184,12 +184,6 @@ configuration option in `gitlab.yml`. These metrics are served from the
| `geo_package_files_synced` | Gauge | 13.3 | Number of syncable package files synced on secondary | `url` |
| `geo_package_files_failed` | Gauge | 13.3 | Number of syncable package files failed to sync on secondary | `url` |
| `geo_package_files_registry` | Gauge | 13.3 | Number of package files in the registry | `url` |
| `geo_terraform_states` | Gauge | 13.3 | Number of terraform states on primary | `url` |
| `geo_terraform_states_checksummed` | Gauge | 13.3 | Number of terraform states checksummed on primary | `url` |
| `geo_terraform_states_checksum_failed` | Gauge | 13.3 | Number of terraform states failed to calculate the checksum on primary | `url` |
| `geo_terraform_states_synced` | Gauge | 13.3 | Number of syncable terraform states synced on secondary | `url` |
| `geo_terraform_states_failed` | Gauge | 13.3 | Number of syncable terraform states failed to sync on secondary | `url` |
| `geo_terraform_states_registry` | Gauge | 13.3 | Number of terraform states in the registry | `url` |
| `geo_terraform_state_versions` | Gauge | 13.5 | Number of terraform state versions on primary | `url` |
| `geo_terraform_state_versions_checksummed` | Gauge | 13.5 | Number of terraform state versions checksummed on primary | `url` |
| `geo_terraform_state_versions_checksum_failed` | Gauge | 13.5 | Number of terraform state versions failed to calculate the checksum on primary | `url` |
......
......@@ -460,12 +460,6 @@ Example response:
"package_files_registry_count": 10,
"package_files_synced_count": 6,
"package_files_failed_count": 3,
"terraform_states_count": 10,
"terraform_states_checksummed_count": 10,
"terraform_states_checksum_failed_count": 0,
"terraform_states_registry_count": 10,
"terraform_states_synced_count": 6,
"terraform_states_failed_count": 3,
"terraform_state_versions_count": 10,
"terraform_state_versions_checksummed_count": 10,
"terraform_state_versions_checksum_failed_count": 0,
......
......@@ -7005,37 +7005,6 @@ type GeoNode {
"""
syncObjectStorage: Boolean
"""
Find terraform state registries on this Geo node. Available only when feature
flag `geo_terraform_state_replication` is enabled
"""
terraformStateRegistries(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Filters registries by their ID
"""
ids: [ID!]
"""
Returns the last _n_ elements from the list.
"""
last: Int
): TerraformStateRegistryConnection
"""
Find terraform state version registries on this Geo node
"""
......@@ -17725,86 +17694,6 @@ type TerraformStateEdge {
node: TerraformState
}
"""
Represents the Geo sync and verification state of a terraform state
"""
type TerraformStateRegistry {
"""
Timestamp when the TerraformStateRegistry was created
"""
createdAt: Time
"""
ID of the TerraformStateRegistry
"""
id: ID!
"""
Error message during sync of the TerraformStateRegistry
"""
lastSyncFailure: String
"""
Timestamp of the most recent successful sync of the TerraformStateRegistry
"""
lastSyncedAt: Time
"""
Timestamp after which the TerraformStateRegistry should be resynced
"""
retryAt: Time
"""
Number of consecutive failed sync attempts of the TerraformStateRegistry
"""
retryCount: Int
"""
Sync state of the TerraformStateRegistry
"""
state: RegistryState
"""
ID of the TerraformState
"""
terraformStateId: ID!
}
"""
The connection type for TerraformStateRegistry.
"""
type TerraformStateRegistryConnection {
"""
A list of edges.
"""
edges: [TerraformStateRegistryEdge]
"""
A list of nodes.
"""
nodes: [TerraformStateRegistry]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
An edge in a connection.
"""
type TerraformStateRegistryEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: TerraformStateRegistry
}
"""
Represents the Geo sync and verification state of a terraform state version
"""
......
......@@ -2484,21 +2484,6 @@ Completion status of tasks.
| `name` | String! | Name of the Terraform state |
| `updatedAt` | Time! | Timestamp the Terraform state was updated |
### TerraformStateRegistry
Represents the Geo sync and verification state of a terraform state.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `createdAt` | Time | Timestamp when the TerraformStateRegistry was created |
| `id` | ID! | ID of the TerraformStateRegistry |
| `lastSyncFailure` | String | Error message during sync of the TerraformStateRegistry |
| `lastSyncedAt` | Time | Timestamp of the most recent successful sync of the TerraformStateRegistry |
| `retryAt` | Time | Timestamp after which the TerraformStateRegistry should be resynced |
| `retryCount` | Int | Number of consecutive failed sync attempts of the TerraformStateRegistry |
| `state` | RegistryState | Sync state of the TerraformStateRegistry |
| `terraformStateId` | ID! | ID of the TerraformState |
### TerraformStateVersionRegistry
Represents the Geo sync and verification state of a terraform state version.
......
# frozen_string_literal: true
module Geo
class TerraformStateRegistryFinder
include FrameworkRegistryFinder
end
end
# frozen_string_literal: true
module Resolvers
module Geo
class TerraformStateRegistriesResolver < BaseResolver
include RegistriesResolver
end
end
end
......@@ -31,11 +31,6 @@ module Types
null: true,
resolver: ::Resolvers::Geo::PackageFileRegistriesResolver,
description: 'Package file registries of the GeoNode'
field :terraform_state_registries, ::Types::Geo::TerraformStateRegistryType.connection_type,
null: true,
resolver: ::Resolvers::Geo::TerraformStateRegistriesResolver,
description: 'Find terraform state registries on this Geo node',
feature_flag: :geo_terraform_state_replication
field :terraform_state_version_registries, ::Types::Geo::TerraformStateVersionRegistryType.connection_type,
null: true,
resolver: ::Resolvers::Geo::TerraformStateVersionRegistriesResolver,
......
# frozen_string_literal: true
module Types
module Geo
# rubocop:disable Graphql/AuthorizeTypes because it is included
class TerraformStateRegistryType < BaseObject
include ::Types::Geo::RegistryType
graphql_name 'TerraformStateRegistry'
description 'Represents the Geo sync and verification state of a terraform state'
field :terraform_state_id, GraphQL::ID_TYPE, null: false, description: 'ID of the TerraformState'
end
end
end
# frozen_string_literal: true
module EE
module Terraform
module State
extend ActiveSupport::Concern
prepended do
include ::Gitlab::Geo::ReplicableModel
with_replicator Geo::TerraformStateReplicator
scope :with_files_stored_locally, -> { where(file_store: ::ObjectStorage::Store::LOCAL) }
scope :project_id_in, ->(ids) { where(project_id: ids) }
end
class_methods do
def replicables_for_geo_node(node = ::Gitlab::Geo.current_node)
selective_sync_scope(node)
.merge(object_storage_scope(node))
.versioning_not_enabled
end
private
def object_storage_scope(node)
return all if node.sync_object_storage?
with_files_stored_locally
end
def selective_sync_scope(node)
return all unless node.selective_sync?
project_id_in(node.projects)
end
end
def log_geo_deleted_event
# Keep empty for now. Should be addressed in future
# by https://gitlab.com/gitlab-org/gitlab/-/issues/232917
end
end
end
end
# frozen_string_literal: true
class Geo::TerraformStateRegistry < Geo::BaseRegistry
include Geo::ReplicableRegistry
MODEL_CLASS = ::Terraform::State
MODEL_FOREIGN_KEY = :terraform_state_id
belongs_to :terraform_state, class_name: 'Terraform::State'
end
# frozen_string_literal: true
module Geo
class TerraformStateReplicator < Gitlab::Geo::Replicator
include ::Geo::BlobReplicatorStrategy
def carrierwave_uploader
model_record.file
end
def handle_after_create_commit
return if model_record.versioning_enabled?
super
end
def handle_after_destroy
return if model_record.versioning_enabled?
super
end
def self.model
::Terraform::State
end
def self.replication_enabled_by_default?
false
end
end
end
......@@ -23,7 +23,6 @@ module Geo
Geo::MergeRequestDiffRegistry,
Geo::PackageFileRegistry,
Geo::ProjectRegistry,
Geo::TerraformStateRegistry,
Geo::TerraformStateVersionRegistry,
Geo::UploadRegistry
].freeze
......
---
title: Remove code for non-versioned terraform state replication
merge_request: 43341
author:
type: changed
---
name: geo_terraform_state_replication
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36594
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/254623
group: group::geo
type: development
default_enabled: false
# frozen_string_literal: true
class RemoveNonVersionedTerraformStateRegistry < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
drop_table :terraform_state_registry
end
def down
unless table_exists?(:terraform_state_registry)
ActiveRecord::Base.transaction do
create_table :terraform_state_registry, id: :bigserial, force: :cascade do |t|
t.datetime_with_timezone :retry_at
t.datetime_with_timezone :last_synced_at
t.datetime_with_timezone :created_at, null: false
t.bigint :terraform_state_id, null: false
t.integer :state, default: 0, null: false, limit: 2
t.integer :retry_count, default: 0, limit: 2
t.text :last_sync_failure
t.index :terraform_state_id
t.index :retry_at
t.index :state
end
end
end
add_text_limit :terraform_state_registry, :last_sync_failure, 255
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_09_15_152620) do
ActiveRecord::Schema.define(version: 2020_09_24_184638) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -196,19 +196,6 @@ ActiveRecord::Schema.define(version: 2020_09_15_152620) do
t.index ["state"], name: "index_snippet_repository_registry_on_state"
end
create_table "terraform_state_registry", force: :cascade do |t|
t.datetime_with_timezone "retry_at"
t.datetime_with_timezone "last_synced_at"
t.datetime_with_timezone "created_at", null: false
t.bigint "terraform_state_id", null: false
t.integer "state", limit: 2, default: 0, null: false
t.integer "retry_count", limit: 2, default: 0
t.text "last_sync_failure"
t.index ["retry_at"], name: "index_terraform_state_registry_on_retry_at"
t.index ["state"], name: "index_terraform_state_registry_on_state"
t.index ["terraform_state_id"], name: "index_terraform_state_registry_on_terraform_state_id"
end
create_table "terraform_state_version_registry", force: :cascade do |t|
t.bigint "terraform_state_version_id", null: false
t.integer "state", limit: 2, default: 0, null: false
......
......@@ -22,7 +22,6 @@ module Gitlab
REPLICATOR_CLASSES = [
::Geo::MergeRequestDiffReplicator,
::Geo::PackageFileReplicator,
::Geo::TerraformStateReplicator,
::Geo::TerraformStateVersionReplicator,
::Geo::SnippetRepositoryReplicator
].freeze
......
# frozen_string_literal: true
FactoryBot.define do
factory :geo_terraform_state_registry, class: 'Geo::TerraformStateRegistry' do
association :terraform_state, factory: :terraform_state
state { Geo::TerraformStateRegistry.state_value(:pending) }
trait :synced do
state { Geo::TerraformStateRegistry.state_value(:synced) }
last_synced_at { 5.days.ago }
end
trait :failed do
state { Geo::TerraformStateRegistry.state_value(:failed) }
last_synced_at { 1.day.ago }
retry_count { 2 }
last_sync_failure { 'Random error' }
end
trait :started do
state { Geo::TerraformStateRegistry.state_value(:started) }
last_synced_at { 1.day.ago }
retry_count { 0 }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::TerraformStateRegistryFinder do
it_behaves_like 'a framework registry finder', :geo_terraform_state_registry
end
......@@ -62,14 +62,6 @@
"package_files_failed_count",
"package_files_synced_count",
"package_files_synced_in_percentage",
"terraform_states_count",
"terraform_states_checksum_failed_count",
"terraform_states_checksummed_in_percentage",
"terraform_states_checksummed_count",
"terraform_states_registry_count",
"terraform_states_failed_count",
"terraform_states_synced_count",
"terraform_states_synced_in_percentage",
"terraform_state_versions_count",
"terraform_state_versions_checksum_failed_count",
"terraform_state_versions_checksummed_in_percentage",
......@@ -183,14 +175,6 @@
"package_files_synced_count": { "type": ["integer", "null"] },
"package_files_synced_in_percentage": { "type": "string" },
"package_files_checksummed_in_percentage": { "type": "string" },
"terraform_states_count": { "type": ["integer", "null"] },
"terraform_states_checksummed_count": { "type": ["integer", "null"] },
"terraform_states_checksum_failed_count": { "type": ["integer", "null"] },
"terraform_states_registry_count": { "type": ["integer", "null"] },
"terraform_states_failed_count": { "type": ["integer", "null"] },
"terraform_states_synced_count": { "type": ["integer", "null"] },
"terraform_states_synced_in_percentage": { "type": "string" },
"terraform_states_checksummed_in_percentage": { "type": "string" },
"terraform_state_versions_count": { "type": ["integer", "null"] },
"terraform_state_versions_checksummed_count": { "type": ["integer", "null"] },
"terraform_state_versions_checksum_failed_count": { "type": ["integer", "null"] },
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::Geo::TerraformStateRegistriesResolver do
it_behaves_like 'a Geo registries resolver', :geo_terraform_state_registry
end
......@@ -12,8 +12,7 @@ RSpec.describe GitlabSchema.types['GeoNode'] do
container_repositories_max_capacity sync_object_storage
selective_sync_type selective_sync_shards selective_sync_namespaces
minimum_reverification_interval merge_request_diff_registries
package_file_registries
terraform_state_registries terraform_state_version_registries
package_file_registries terraform_state_version_registries
]
expect(described_class).to have_graphql_fields(*expected_fields)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['TerraformStateRegistry'] do
it_behaves_like 'a Geo registry type'
it 'has the expected fields (other than those included in RegistryType)' do
expected_fields = %i[terraform_state_id]
expect(described_class).to have_graphql_fields(*expected_fields).at_least
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Terraform::State do
using RSpec::Parameterized::TableSyntax
include EE::GeoHelpers
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
subject { create(:terraform_state, :with_file) }
describe '.with_files_stored_locally' do
it 'includes states with local storage' do
create_list(:terraform_state, 5, :with_file)
expect(described_class.with_files_stored_locally).to have_attributes(count: 5)
end
it 'excludes states without local storage' do
stub_terraform_state_object_storage
create_list(:terraform_state, 5, :with_file)
expect(described_class.with_files_stored_locally).to have_attributes(count: 0)
end
end
describe '.replicables_for_geo_node' do
where(:selective_sync_enabled, :object_storage_sync_enabled, :terraform_object_storage_enabled, :synced_states) do
true | true | true | 5
true | true | false | 5
true | false | true | 0
true | false | false | 5
false | false | false | 10
false | false | true | 0
false | true | true | 10
false | true | false | 10
true | true | false | 5
end
with_them do
let(:secondary) do
node = build(:geo_node, sync_object_storage: object_storage_sync_enabled)
if selective_sync_enabled
node.selective_sync_type = 'namespaces'
node.namespaces = [group]
end
node.save!
node
end
before do
stub_current_geo_node(secondary)
stub_terraform_state_object_storage if terraform_object_storage_enabled
create_list(:terraform_state, 5, :with_file, project: project)
create_list(:terraform_state, 5, :with_file, project: create(:project))
end
it 'returns the proper number of terraform states' do
expect(Terraform::State.replicables_for_geo_node.count).to eq(synced_states)
end
end
context 'state versioning' do
let(:secondary) { create(:geo_node, sync_object_storage: true) }
before do
stub_current_geo_node(secondary)
stub_terraform_state_object_storage
create_list(:terraform_state, 5, project: project)
end
it 'excludes versioned states' do
expect(Terraform::State.replicables_for_geo_node.count).to be_zero
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::TerraformStateRegistry, :geo, type: :model do
let_it_be(:registry) { create(:geo_terraform_state_registry) }
specify 'factory is valid' do
expect(registry).to be_valid
end
include_examples 'a Geo framework registry'
end
......@@ -1149,7 +1149,6 @@ RSpec.describe GeoNodeStatus, :geo do
where(:replicator, :model_factory, :registry_factory) do
Geo::MergeRequestDiffReplicator | :external_merge_request_diff | :geo_merge_request_diff_registry
Geo::PackageFileReplicator | :package_file | :geo_package_file_registry
Geo::TerraformStateReplicator | :terraform_state | :geo_terraform_state_registry
Geo::TerraformStateVersionReplicator | :terraform_state_version | :geo_terraform_state_version_registry
Geo::SnippetRepositoryReplicator | :snippet_repository | :geo_snippet_repository_registry
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::TerraformStateReplicator do
let(:model_record) { build(:terraform_state, :with_file) }
it_behaves_like 'a blob replicator'
context 'Terraform state versioning is enabled' do
let(:model_record) { build(:terraform_state, :with_version) }
let(:replicator) { model_record.replicator }
describe '#handle_after_create_commit' do
subject { replicator.handle_after_create_commit }
it 'does not create a Geo::Event' do
expect { subject }.not_to change { ::Geo::Event.count }
end
end
describe '#handle_after_destroy' do
subject { replicator.handle_after_destroy }
it 'does not create a Geo::Event' do
expect { subject }.not_to change { ::Geo::Event.count }
end
end
end
end
......@@ -17,13 +17,6 @@ RSpec.describe 'Gets registries' do
registry_foreign_key_field_name: 'packageFileId'
}
it_behaves_like 'gets registries for', {
field_name: 'terraformStateRegistries',
registry_class_name: 'TerraformStateRegistry',
registry_factory: :geo_terraform_state_registry,
registry_foreign_key_field_name: 'terraformStateId'
}
it_behaves_like 'gets registries for', {
field_name: 'terraformStateVersionRegistries',
registry_class_name: 'TerraformStateVersionRegistry',
......
......@@ -19,7 +19,6 @@ RSpec.describe Geo::RegistryConsistencyService, :geo, :use_clean_rails_memory_st
{ Geo::DesignRegistry => :project_with_design,
Geo::MergeRequestDiffRegistry => :external_merge_request_diff,
Geo::PackageFileRegistry => :package_file_with_file,
Geo::TerraformStateRegistry => :legacy_terraform_state,
Geo::TerraformStateVersionRegistry => :terraform_state_version }
.fetch(registry_class, default_factory_name)
end
......
......@@ -85,7 +85,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
lfs_object = create(:lfs_object)
merge_request_diff = create(:merge_request_diff, :external)
package_file = create(:conan_package_file, :conan_package)
terraform_state = create(:legacy_terraform_state, project: project)
terraform_state_version = create(:terraform_state_version)
upload = create(:upload)
......@@ -96,7 +95,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
expect(Geo::MergeRequestDiffRegistry.where(merge_request_diff_id: merge_request_diff.id).count).to eq(0)
expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(0)
expect(Geo::ProjectRegistry.where(project_id: project.id).count).to eq(0)
expect(Geo::TerraformStateRegistry.where(terraform_state_id: terraform_state.id).count).to eq(0)
expect(Geo::TerraformStateVersionRegistry.where(terraform_state_version_id: terraform_state_version.id).count).to eq(0)
expect(Geo::UploadRegistry.where(file_id: upload.id).count).to eq(0)
......@@ -109,7 +107,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
expect(Geo::MergeRequestDiffRegistry.where(merge_request_diff_id: merge_request_diff.id).count).to eq(1)
expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(1)
expect(Geo::ProjectRegistry.where(project_id: project.id).count).to eq(1)
expect(Geo::TerraformStateRegistry.where(terraform_state_id: terraform_state.id).count).to eq(1)
expect(Geo::TerraformStateVersionRegistry.where(terraform_state_version_id: terraform_state_version.id).count).to eq(1)
expect(Geo::UploadRegistry.where(file_id: upload.id).count).to eq(1)
end
......@@ -131,23 +128,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo do
end
end
context 'when geo_terraform_state_replication is disabled' do
before do
stub_feature_flags(geo_terraform_state_replication: false)
end
it 'returns false' do
expect(subject.perform).to be_falsey
end
it 'does not execute RegistryConsistencyService for terraform states' do
allow(Geo::RegistryConsistencyService).to receive(:new).and_call_original
expect(Geo::RegistryConsistencyService).not_to receive(:new).with(Geo::TerraformStateRegistry, batch_size: batch_size)
subject.perform
end
end
context 'when the current Geo node is disabled or primary' do
before do
stub_primary_node
......
......@@ -17,16 +17,6 @@ FactoryBot.define do
locked_by_user { create(:user) }
end
trait(:checksummed) do
with_file
verification_checksum { 'abc' }
end
trait(:checksum_failure) do
with_file
verification_failure { 'Could not calculate the checksum' }
end
trait :with_version do
after(:create) do |state|
create(:terraform_state_version, :with_file, terraform_state: state)
......
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