diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-09 03:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-09 03:09:46 +0300 |
commit | b3c9b2468d3d45445ecd6873ad90ca0d34a8ab97 (patch) | |
tree | 829735adf37bfcf6839ed06e6842d7598a303e68 /app/models/container_repository.rb | |
parent | 81c0f29ad962733b0750bdab2d3250e2c796a578 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/container_repository.rb')
-rw-r--r-- | app/models/container_repository.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb index bd2a12c7698..92e53beebae 100644 --- a/app/models/container_repository.rb +++ b/app/models/container_repository.rb @@ -17,6 +17,7 @@ class ContainerRepository < ApplicationRecord SKIPPABLE_MIGRATION_STATES = (ABORTABLE_MIGRATION_STATES + %w[import_aborted]).freeze MIGRATION_PHASE_1_STARTED_AT = Date.new(2021, 11, 4).freeze + MIGRATION_PHASE_1_ENDED_AT = Date.new(2022, 01, 23).freeze TooManyImportsError = Class.new(StandardError) @@ -58,8 +59,8 @@ class ContainerRepository < ApplicationRecord scope :import_in_process, -> { where(migration_state: %w[pre_importing pre_import_done importing]) } scope :recently_done_migration_step, -> do - where(migration_state: %w[import_done pre_import_done import_aborted]) - .order(Arel.sql('GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at) DESC')) + where(migration_state: %w[import_done pre_import_done import_aborted import_skipped]) + .order(Arel.sql('GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at, migration_skipped_at) DESC')) end scope :ready_for_import, -> do @@ -160,7 +161,7 @@ class ContainerRepository < ApplicationRecord end end - before_transition %i[pre_importing import_aborted] => :pre_import_done do |container_repository| + before_transition any => :pre_import_done do |container_repository| container_repository.migration_pre_import_done_at = Time.zone.now end @@ -217,6 +218,13 @@ class ContainerRepository < ApplicationRecord ).exists? end + def self.all_migrated? + # check that the set of non migrated repositories is empty + where(created_at: ...MIGRATION_PHASE_1_ENDED_AT) + .where.not(migration_state: 'import_done') + .empty? + end + def self.with_enabled_policy joins('INNER JOIN container_expiration_policies ON container_repositories.project_id = container_expiration_policies.project_id') .where(container_expiration_policies: { enabled: true }) @@ -359,7 +367,7 @@ class ContainerRepository < ApplicationRecord end def last_import_step_done_at - [migration_pre_import_done_at, migration_import_done_at, migration_aborted_at].compact.max + [migration_pre_import_done_at, migration_import_done_at, migration_aborted_at, migration_skipped_at].compact.max end def external_import_status @@ -456,7 +464,7 @@ class ContainerRepository < ApplicationRecord next if self.created_at.before?(MIGRATION_PHASE_1_STARTED_AT) next unless gitlab_api_client.supports_gitlab_api? - gitlab_api_client.repository_details(self.path, with_size: true)['size_bytes'] + gitlab_api_client.repository_details(self.path, sizing: :self)['size_bytes'] end end |