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
6fa0d0ed
Commit
6fa0d0ed
authored
Jul 17, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to find container registries to sync
parent
d47f531a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
83 deletions
+166
-83
ee/app/finders/geo/container_repository_registry_finder.rb
ee/app/finders/geo/container_repository_registry_finder.rb
+40
-4
ee/app/models/geo/container_repository_registry.rb
ee/app/models/geo/container_repository_registry.rb
+1
-0
ee/spec/finders/geo/container_repository_registry_finder_spec.rb
.../finders/geo/container_repository_registry_finder_spec.rb
+125
-79
No files found.
ee/app/finders/geo/container_repository_registry_finder.rb
View file @
6fa0d0ed
...
...
@@ -30,6 +30,42 @@ module Geo
[
untracked_ids
,
unused_tracked_ids
]
end
# Returns Geo::ContainerRepositoryRegistry records that have never been synced.
#
# Does not care about selective sync, because it considers the Registry
# table to be the single source of truth. The contract is that other
# processes need to ensure that the table only contains records that should
# be synced.
#
# Any registries that have ever been synced that currently need to be
# resynced will be handled by other find methods (like
# #find_retryable_dirty_registries)
#
# You can pass a list with `except_ids:` so you can exclude items you
# already scheduled but haven't finished and aren't persisted to the database yet
#
# @param [Integer] batch_size used to limit the results returned
# @param [Array<Integer>] except_ids ids that will be ignored from the query
# rubocop:disable CodeReuse/ActiveRecord
def
find_never_synced_registries
(
batch_size
:,
except_ids:
[])
Geo
::
ContainerRepositoryRegistry
.
never_synced
.
model_id_not_in
(
except_ids
)
.
limit
(
batch_size
)
end
# rubocop:enable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
Geo
::
ContainerRepositoryRegistry
.
failed
.
retry_due
.
model_id_not_in
(
except_ids
)
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_synced_at
))
.
limit
(
batch_size
)
end
# rubocop:enable CodeReuse/ActiveRecord
# Find limited amount of non replicated container repositories.
#
# You can pass a list with `except_repository_ids:` so you can exclude items you
...
...
@@ -37,16 +73,16 @@ module Geo
#
# @param [Integer] batch_size used to limit the results returned
# @param [Array<Integer>] except_repository_ids ids that will be ignored from the query
# rubocop:
disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_unsynced
(
batch_size
:,
except_repository_ids:
[])
container_repositories
.
missing_container_repository_registry
.
id_not_in
(
except_repository_ids
)
.
limit
(
batch_size
)
end
# rubocop:
enable CodeReuse/ActiveRecord
# rubocop:enable CodeReuse/ActiveRecord
# rubocop:
disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_failed_ids
(
batch_size
:,
except_repository_ids:
[])
Geo
::
ContainerRepositoryRegistry
.
failed
...
...
@@ -55,7 +91,7 @@ module Geo
.
limit
(
batch_size
)
.
pluck_container_repository_key
end
# rubocop:
enable CodeReuse/ActiveRecord
# rubocop:enable CodeReuse/ActiveRecord
private
...
...
ee/app/models/geo/container_repository_registry.rb
View file @
6fa0d0ed
...
...
@@ -8,6 +8,7 @@ class Geo::ContainerRepositoryRegistry < Geo::BaseRegistry
belongs_to
:container_repository
scope
:never_synced
,
->
{
with_state
(
:pending
).
where
(
last_synced_at:
nil
)
}
scope
:failed
,
->
{
with_state
(
:failed
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
...
...
ee/spec/finders/geo/container_repository_registry_finder_spec.rb
View file @
6fa0d0ed
This diff is collapsed.
Click to expand it.
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