Geo: Verification of Uploads
What does this MR do?
Adds verification to recently added Upload replication using SSF
Migration queries
db/migrate/20211101165656_create_upload_states.rb
Up:
== 20211101165656 CreateUploadStates: migrating ===============================
-- create_table(:upload_states, {:id=>false})
-- quote_column_name(:verification_failure)
-> 0.0000s
-> 0.0205s
== 20211101165656 CreateUploadStates: migrated (0.0206s) ======================
Down:
== 20211101165656 CreateUploadStates: reverting ===============================
-- drop_table(:upload_states)
-> 0.0182s
== 20211101165656 CreateUploadStates: reverted (0.0183s) ======================
Geo Database
ee/db/geo/migrate/20211101113611_prepare_file_registry_for_verification.rb
Up:
== 20211101113611 PrepareFileRegistryForVerification: migrating ===============
-- add_column(:file_registry, :verified_at, :datetime_with_timezone)
-> 0.0009s
-- add_column(:file_registry, :verification_started_at, :datetime_with_timezone)
-> 0.0006s
-- add_column(:file_registry, :verification_retry_at, :datetime_with_timezone)
-> 0.0006s
-- add_column(:file_registry, :verification_state, :integer, {:default=>0, :null=>false, :limit=>2})
-> 0.0013s
-- add_column(:file_registry, :verification_retry_count, :integer, {:default=>0, :limit=>2, :null=>false})
-> 0.0011s
-- add_column(:file_registry, :verification_checksum, :binary)
-> 0.0005s
-- add_column(:file_registry, :verification_checksum_mismatched, :binary)
-> 0.0006s
-- add_column(:file_registry, :checksum_mismatch, :boolean, {:default=>false, :null=>false})
-> 0.0010s
-- add_column(:file_registry, :verification_failure, :text)
-> 0.0006s
== 20211101113611 PrepareFileRegistryForVerification: migrated (0.0078s) ======
Down:
== 20211101113611 PrepareFileRegistryForVerification: reverting ===============
-- remove_column(:file_registry, :verified_at)
-> 0.0011s
-- remove_column(:file_registry, :verification_started_at)
-> 0.0009s
-- remove_column(:file_registry, :verification_retry_at)
-> 0.0009s
-- remove_column(:file_registry, :verification_state)
-> 0.0011s
-- remove_column(:file_registry, :verification_retry_count)
-> 0.0011s
-- remove_column(:file_registry, :verification_checksum)
-> 0.0008s
-- remove_column(:file_registry, :verification_checksum_mismatched)
-> 0.0007s
-- remove_column(:file_registry, :checksum_mismatch)
-> 0.0008s
-- remove_column(:file_registry, :verification_failure)
-> 0.0007s
== 20211101113611 PrepareFileRegistryForVerification: reverted (0.0089s) ======
ee/db/geo/migrate/20211102121712_create_file_registry_verification_indexies.rb
Up:
== 20211102121712 CreateFileRegistryVerificationIndexies: migrating ===========
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verification_retry_at, {:name=>:file_registry_failed_verification, :order=>"NULLS FIRST", :where=>"((state = 2) AND (verification_state = 3))", :algorithm=>:concurrently})
-> 0.0018s
-- add_index(:file_registry, :verification_retry_at, {:name=>:file_registry_failed_verification, :order=>"NULLS FIRST", :where=>"((state = 2) AND (verification_state = 3))", :algorithm=>:concurrently})
-> 0.0013s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verification_state, {:name=>:file_registry_needs_verification, :where=>"((state = 2) AND (verification_state = ANY (ARRAY[0, 3])))", :algorithm=>:concurrently})
-> 0.0019s
-- add_index(:file_registry, :verification_state, {:name=>:file_registry_needs_verification, :where=>"((state = 2) AND (verification_state = ANY (ARRAY[0, 3])))", :algorithm=>:concurrently})
-> 0.0012s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verified_at, {:name=>:file_registry_pending_verification, :order=>"NULLS FIRST", :where=>"((state = 2) AND (verification_state = 0))", :algorithm=>:concurrently})
-> 0.0024s
-- add_index(:file_registry, :verified_at, {:name=>:file_registry_pending_verification, :order=>"NULLS FIRST", :where=>"((state = 2) AND (verification_state = 0))", :algorithm=>:concurrently})
-> 0.0013s
== 20211102121712 CreateFileRegistryVerificationIndexies: migrated (0.0142s) ==
Down:
== 20211102121712 CreateFileRegistryVerificationIndexies: reverting ===========
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verification_retry_at, {:name=>:file_registry_failed_verification, :algorithm=>:concurrently})
-> 0.0061s
-- remove_index(:file_registry, {:name=>:file_registry_failed_verification, :algorithm=>:concurrently, :column=>:verification_retry_at})
-> 0.0054s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verification_state, {:name=>:file_registry_needs_verification, :algorithm=>:concurrently})
-> 0.0034s
-- remove_index(:file_registry, {:name=>:file_registry_needs_verification, :algorithm=>:concurrently, :column=>:verification_state})
-> 0.0043s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:file_registry, :verified_at, {:name=>:file_registry_pending_verification, :algorithm=>:concurrently})
-> 0.0029s
-- remove_index(:file_registry, {:name=>:file_registry_pending_verification, :algorithm=>:concurrently, :column=>:verified_at})
-> 0.0041s
== 20211102121712 CreateFileRegistryVerificationIndexies: reverted (0.0328s) ==
ee/db/geo/migrate/20211126312431_add_text_limit_to_file_registry_verification_failure.rb
Up:
== 20211126312431 AddTextLimitToFileRegistryVerificationFailure: migrating ====
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0004s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE file_registry\nADD CONSTRAINT check_1886652634\nCHECK ( char_length(verification_failure) <= 256 )\nNOT VALID;\n")
-> 0.0007s
-- current_schema()
-> 0.0004s
-- execute("ALTER TABLE file_registry VALIDATE CONSTRAINT check_1886652634;")
-> 0.0006s
== 20211126312431 AddTextLimitToFileRegistryVerificationFailure: migrated (0.0073s)
Down:
== 20211126312431 AddTextLimitToFileRegistryVerificationFailure: reverting ====
-- transaction_open?()
-> 0.0000s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE file_registry\nDROP CONSTRAINT IF EXISTS check_1886652634\n")
-> 0.0015s
== 20211126312431 AddTextLimitToFileRegistryVerificationFailure: reverted (0.0105s)
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #270449 (closed)
Edited by Valery Sizov