Geo: Spike skeleton of Repository Strategy for Snippets

Merged Valery Sizov requested to merge 211899-geo-publish-snippets-replication-events into master

What does this MR do?

Spike skeleton of Repository Strategy for Snippets. This MR mostly consists of steps from our Geo SSF guide + some fixes specific to Snippets. I aimed to create as short diff as possible but unfortunately, lots of shared examples in specs that help us to DRY up the test suite can't work partially, so it would not be efficient to implement the feature partially. There is also one thing that justifies the large diff - most of the changes are template changes.

Closes #234120 (closed)

Closes #211899 (closed)

and many more from epic &2809 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • 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

Migrations

ee/db/geo/migrate/20200811171011_create_snippet_repository_registry.rb.

Down:

== 20200811171011 CreateSnippetRepositoryRegistry: reverting ==================
-- drop_table(:snippet_repository_registry)
   -> 0.0181s
== 20200811171011 CreateSnippetRepositoryRegistry: reverted (0.0182s) =========

Up:

== 20200811171011 CreateSnippetRepositoryRegistry: migrating ==================
-- create_table(:snippet_repository_registry, {:id=>:bigserial, :force=>:cascade})
   -> 0.0268s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE snippet_repository_registry\nADD CONSTRAINT check_5409cb1003\nCHECK ( char_length(last_sync_failure) <= 255 )\nNOT VALID;\n")
   -> 0.0010s
-- execute("ALTER TABLE snippet_repository_registry VALIDATE CONSTRAINT check_5409cb1003;")
   -> 0.0004s
== 20200811171011 CreateSnippetRepositoryRegistry: migrated (0.0341s) =========

db/migrate/20200812150812_add_verification_failure_index_to_snippet_repository.rb

Down:

== 20200812150812 AddVerificationFailureIndexToSnippetRepository: reverting ===
-- transaction_open?()
   -> 0.0000s
-- indexes(:snippet_repositories)
   -> 0.0033s
-- remove_index(:snippet_repositories, {:algorithm=>:concurrently, :name=>"snippet_repositories_verification_failure_partial"})
   -> 0.0040s
-- transaction_open?()
   -> 0.0000s
-- indexes(:snippet_repositories)
   -> 0.0016s
-- remove_index(:snippet_repositories, {:algorithm=>:concurrently, :name=>"snippet_repositories_verification_checksum_partial"})
   -> 0.0014s
== 20200812150812 AddVerificationFailureIndexToSnippetRepository: reverted (0.0109s)

Up:

== 20200812150812 AddVerificationFailureIndexToSnippetRepository: migrating ===
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:snippet_repositories, :verification_failure, {:where=>"(verification_failure IS NOT NULL)", :name=>"snippet_repositories_verification_failure_partial", :algorithm=>:concurrently})
   -> 0.0020s
-- add_index(:snippet_repositories, :verification_failure, {:where=>"(verification_failure IS NOT NULL)", :name=>"snippet_repositories_verification_failure_partial", :algorithm=>:concurrently})
   -> 0.0031s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:snippet_repositories, :verification_checksum, {:where=>"(verification_checksum IS NOT NULL)", :name=>"snippet_repositories_verification_checksum_partial", :algorithm=>:concurrently})
   -> 0.0018s
-- add_index(:snippet_repositories, :verification_checksum, {:where=>"(verification_checksum IS NOT NULL)", :name=>"snippet_repositories_verification_checksum_partial", :algorithm=>:concurrently})
   -> 0.0022s
== 20200812150812 AddVerificationFailureIndexToSnippetRepository: migrated (0.0098s)

db/migrate/20200812150811_add_verification_failure_to_snippet_repository.rb

Down:

== 20200812150811 AddVerificationFailureToSnippetRepository: reverting ========
-- execute("ALTER TABLE snippet_repositories\nDROP CONSTRAINT IF EXISTS snippet_repositories_text_limit\n")
   -> 0.0022s
== 20200812150811 AddVerificationFailureToSnippetRepository: reverted (0.0080s)

Up:

== 20200812150811 AddVerificationFailureToSnippetRepository: migrating ========
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE snippet_repositories\nADD CONSTRAINT snippet_repositories_text_limit\nCHECK ( char_length(verification_failure) <= 255 )\nNOT VALID;\n")
   -> 0.0014s
-- execute("ALTER TABLE snippet_repositories VALIDATE CONSTRAINT snippet_repositories_text_limit;")
   -> 0.0005s
== 20200812150811 AddVerificationFailureToSnippetRepository: migrated (0.0083s)

db/migrate/20200812150810_add_verification_state_to_snippet_repository.rb

Down:

== 20200812150810 AddVerificationStateToSnippetRepository: reverting ==========
-- remove_column(:snippet_repositories, :verification_failure, :text, {})
   -> 0.0019s
-- remove_column(:snippet_repositories, :verification_checksum, :binary, {:using=>"verification_checksum::bytea"})
   -> 0.0003s
-- remove_column(:snippet_repositories, :verified_at, :datetime_with_timezone, {})
   -> 0.0003s
-- remove_column(:snippet_repositories, :verification_retry_at, :datetime_with_timezone, {})
   -> 0.0003s
-- remove_column(:snippet_repositories, :verification_retry_count, :integer, {:limit=>2})
   -> 0.0002s
== 20200812150810 AddVerificationStateToSnippetRepository: reverted (0.0054s) =

Up:

== 20200812150810 AddVerificationStateToSnippetRepository: migrating ==========
-- change_table(:snippet_repositories)
   -> 0.0029s
== 20200812150810 AddVerificationStateToSnippetRepository: migrated (0.0029s) =
Edited by Michael Kozono