Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9141a5e8
Commit
9141a5e8
authored
Mar 22, 2022
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle native imports
in the ContainerRepository migration logic
parent
aef3a688
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
app/models/container_repository.rb
app/models/container_repository.rb
+11
-3
spec/models/container_repository_spec.rb
spec/models/container_repository_spec.rb
+20
-0
spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb
...es/requests/api/container_repositories_shared_examples.rb
+4
-2
No files found.
app/models/container_repository.rb
View file @
9141a5e8
...
...
@@ -21,7 +21,6 @@ class ContainerRepository < ApplicationRecord
MIGRATION_PHASE_1_STARTED_AT
=
Date
.
new
(
2021
,
11
,
4
).
freeze
TooManyImportsError
=
Class
.
new
(
StandardError
)
NativeImportError
=
Class
.
new
(
StandardError
)
belongs_to
:project
...
...
@@ -36,7 +35,7 @@ class ContainerRepository < ApplicationRecord
enum
status:
{
delete_scheduled:
0
,
delete_failed:
1
}
enum
expiration_policy_cleanup_status:
{
cleanup_unscheduled:
0
,
cleanup_scheduled:
1
,
cleanup_unfinished:
2
,
cleanup_ongoing:
3
}
enum
migration_skipped_reason:
{
not_in_plan:
0
,
too_many_retries:
1
,
too_many_tags:
2
,
root_namespace_in_deny_list:
3
,
migration_canceled:
4
,
not_found:
5
}
enum
migration_skipped_reason:
{
not_in_plan:
0
,
too_many_retries:
1
,
too_many_tags:
2
,
root_namespace_in_deny_list:
3
,
migration_canceled:
4
,
not_found:
5
,
native_import:
6
}
delegate
:client
,
:gitlab_api_client
,
to: :registry
...
...
@@ -295,7 +294,7 @@ class ContainerRepository < ApplicationRecord
def
reconcile_import_status
(
status
)
case
status
when
'native'
raise
NativeImportError
finish_import_as_native
when
*
IRRECONCILABLE_MIGRATIONS_STATUSES
nil
when
'import_complete'
...
...
@@ -323,6 +322,8 @@ class ContainerRepository < ApplicationRecord
return
true
when
:not_found
skip_import
(
reason: :not_found
)
when
:already_imported
finish_import_as_native
else
abort_import
end
...
...
@@ -509,6 +510,13 @@ class ContainerRepository < ApplicationRecord
self
.
find_by
(
project:
path
.
repository_project
,
name:
path
.
repository_name
)
end
private
def
finish_import_as_native
self
.
migration_skipped_reason
=
:native_import
finish_import
end
end
ContainerRepository
.
prepend_mod_with
(
'ContainerRepository'
)
spec/models/container_repository_spec.rb
View file @
9141a5e8
...
...
@@ -122,6 +122,16 @@ RSpec.describe ContainerRepository, :aggregate_failures do
expect
(
repository
).
to
be_import_aborted
end
end
context
'already imported'
do
it
'finishes the import'
do
expect
(
repository
).
to
receive
(
:migration_pre_import
).
and_return
(
:already_imported
)
expect
{
subject
}
.
to
change
{
repository
.
reload
.
migration_state
}.
to
(
'import_done'
)
.
and
change
{
repository
.
reload
.
migration_skipped_reason
}.
to
(
'native_import'
)
end
end
end
shared_examples
'transitioning to importing'
,
skip_import_success:
true
do
...
...
@@ -151,6 +161,16 @@ RSpec.describe ContainerRepository, :aggregate_failures do
expect
(
repository
).
to
be_import_aborted
end
end
context
'already imported'
do
it
'finishes the import'
do
expect
(
repository
).
to
receive
(
:migration_import
).
and_return
(
:already_imported
)
expect
{
subject
}
.
to
change
{
repository
.
reload
.
migration_state
}.
to
(
'import_done'
)
.
and
change
{
repository
.
reload
.
migration_skipped_reason
}.
to
(
'native_import'
)
end
end
end
shared_examples
'transitioning out of import_aborted'
do
...
...
spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb
View file @
9141a5e8
...
...
@@ -145,8 +145,10 @@ RSpec.shared_examples 'reconciling migration_state' do
context
'native response'
do
let
(
:status
)
{
'native'
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
described_class
::
NativeImportError
)
it
'finishes the import'
do
expect
{
subject
}
.
to
change
{
repository
.
reload
.
migration_state
}.
to
(
'import_done'
)
.
and
change
{
repository
.
reload
.
migration_skipped_reason
}.
to
(
'native_import'
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment