diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /.gitlab/issue_templates/Geo Replicate a new Git repository type.md | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to '.gitlab/issue_templates/Geo Replicate a new Git repository type.md')
-rw-r--r-- | .gitlab/issue_templates/Geo Replicate a new Git repository type.md | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md index 71a962d1789..f4f70a38a27 100644 --- a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md +++ b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md @@ -56,9 +56,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org ```ruby # frozen_string_literal: true - class CreateCoolWidgetRegistry < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - + class CreateCoolWidgetRegistry < Gitlab::Database::Migration[1.0] disable_ddl_transaction! def up @@ -80,8 +78,8 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org t.boolean :missing_on_primary, default: false, null: false t.binary :verification_checksum t.binary :verification_checksum_mismatched - t.string :verification_failure, limit: 255 # rubocop:disable Migration/PreventStrings see https://gitlab.com/gitlab-org/gitlab/-/issues/323806 - t.string :last_sync_failure, limit: 255 # rubocop:disable Migration/PreventStrings see https://gitlab.com/gitlab-org/gitlab/-/issues/323806 + t.text :verification_failure, limit: 255 + t.text :last_sync_failure, limit: 255 t.index :cool_widget_id, name: :index_cool_widget_registry_on_cool_widget_id, unique: true t.index :retry_at @@ -126,9 +124,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ```ruby # frozen_string_literal: true - class CreateCoolWidgetStates < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - + class CreateCoolWidgetStates < Gitlab::Database::Migration[1.0] VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state" PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification" FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification" @@ -137,27 +133,23 @@ The Geo primary site needs to checksum every replicable so secondaries can verif disable_ddl_transaction! def up - unless table_exists?(:cool_widget_states) - with_lock_retries do - create_table :cool_widget_states, id: false do |t| - t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade } - t.integer :verification_state, default: 0, limit: 2, null: false - t.column :verification_started_at, :datetime_with_timezone - t.datetime_with_timezone :verification_retry_at - t.datetime_with_timezone :verified_at - t.integer :verification_retry_count, limit: 2 - t.binary :verification_checksum, using: 'verification_checksum::bytea' - t.text :verification_failure - - t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME - t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME - t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME - t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME - end + with_lock_retries do + create_table :cool_widget_states, id: false do |t| + t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade } + t.integer :verification_state, default: 0, limit: 2, null: false + t.column :verification_started_at, :datetime_with_timezone + t.datetime_with_timezone :verification_retry_at + t.datetime_with_timezone :verified_at + t.integer :verification_retry_count, limit: 2 + t.binary :verification_checksum, using: 'verification_checksum::bytea' + t.text :verification_failure, limit: 255 + + t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME + t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME + t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME + t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME end end - - add_text_limit :cool_widget_states, :verification_failure, 255 end def down @@ -209,6 +201,8 @@ That's all of the required database changes. has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState' + after_save :save_verification_details + delegate :verification_retry_at, :verification_retry_at=, :verified_at, :verified_at=, :verification_checksum, :verification_checksum=, @@ -223,6 +217,8 @@ That's all of the required database changes. scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) } scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) } + scope :available_verifiables, -> { joins(:cool_widget_state) } + # Override the `all` default if not all records can be replicated. For an # example of an existing Model that needs to do this, see # `EE::MergeRequestDiff`. @@ -358,10 +354,11 @@ That's all of the required database changes. - [ ] Make sure a Geo secondary site can replicate Cool Widgets where repository does not exist on the Geo primary site. The only way to know about this is to parse the error text. You may need to make some changes to `Gitlab::CoolWidgetReplicator.no_repo_message` to return the proper error message. For example, see [this change for Group-level Wikis](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74133). -- [ ] Generate the feature flag definition file by running the feature flag command and following the command prompts: +- [ ] Generate the feature flag definition files by running the feature flag commands and following the command prompts: ```shell bin/feature-flag --ee geo_cool_widget_replication --type development --group 'group::geo' + bin/feature-flag --ee geo_cool_widget_verification --type development --group 'group::geo' ``` - [ ] Add this replicator class to the method `replicator_classes` in @@ -494,6 +491,9 @@ That's all of the required database changes. self.primary_key = :cool_widget_id belongs_to :cool_widget, inverse_of: :cool_widget_state + + validates :verification_failure, length: { maximum: 255 } + validates :verification_state, :cool_widget, presence: true end end ``` |