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
2442d007
Commit
2442d007
authored
Aug 26, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract retryable scope
Refactor code to make the finder class closer to a Geo replicator.
parent
2c191849
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
15 additions
and
31 deletions
+15
-31
ee/app/finders/geo/container_repository_registry_finder.rb
ee/app/finders/geo/container_repository_registry_finder.rb
+1
-2
ee/app/finders/geo/design_registry_finder.rb
ee/app/finders/geo/design_registry_finder.rb
+1
-1
ee/app/finders/geo/file_registry_finder.rb
ee/app/finders/geo/file_registry_finder.rb
+1
-2
ee/app/finders/geo/project_registry_finder.rb
ee/app/finders/geo/project_registry_finder.rb
+1
-2
ee/app/models/concerns/geo/replicable_registry.rb
ee/app/models/concerns/geo/replicable_registry.rb
+1
-0
ee/app/models/concerns/geo/syncable.rb
ee/app/models/concerns/geo/syncable.rb
+5
-3
ee/app/models/geo/base_registry.rb
ee/app/models/geo/base_registry.rb
+1
-2
ee/app/models/geo/container_repository_registry.rb
ee/app/models/geo/container_repository_registry.rb
+1
-0
ee/app/models/geo/design_registry.rb
ee/app/models/geo/design_registry.rb
+1
-4
ee/app/models/geo/job_artifact_registry.rb
ee/app/models/geo/job_artifact_registry.rb
+0
-6
ee/app/models/geo/lfs_object_registry.rb
ee/app/models/geo/lfs_object_registry.rb
+0
-6
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+2
-1
ee/app/models/geo/upload_registry.rb
ee/app/models/geo/upload_registry.rb
+0
-2
No files found.
ee/app/finders/geo/container_repository_registry_finder.rb
View file @
2442d007
...
@@ -5,8 +5,7 @@ module Geo
...
@@ -5,8 +5,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
registry_class
registry_class
.
failed
.
retryable
.
retry_due
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_synced_at
))
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_synced_at
))
.
limit
(
batch_size
)
.
limit
(
batch_size
)
...
...
ee/app/finders/geo/design_registry_finder.rb
View file @
2442d007
...
@@ -5,7 +5,7 @@ module Geo
...
@@ -5,7 +5,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
registry_class
registry_class
.
updated_recently
.
retryable
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_synced_at
))
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_synced_at
))
.
limit
(
batch_size
)
.
limit
(
batch_size
)
...
...
ee/app/finders/geo/file_registry_finder.rb
View file @
2442d007
...
@@ -20,8 +20,7 @@ module Geo
...
@@ -20,8 +20,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_failed_registries
(
batch_size
:,
except_ids:
[])
def
find_retryable_failed_registries
(
batch_size
:,
except_ids:
[])
registry_class
registry_class
.
failed
.
retryable
.
retry_due
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
limit
(
batch_size
)
.
limit
(
batch_size
)
end
end
...
...
ee/app/finders/geo/project_registry_finder.rb
View file @
2442d007
...
@@ -30,8 +30,7 @@ module Geo
...
@@ -30,8 +30,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
def
find_retryable_dirty_registries
(
batch_size
:,
except_ids:
[])
Geo
::
ProjectRegistry
Geo
::
ProjectRegistry
.
dirty
.
retryable
.
retry_due
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_repository_synced_at
))
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_repository_synced_at
))
.
limit
(
batch_size
)
.
limit
(
batch_size
)
...
...
ee/app/models/concerns/geo/replicable_registry.rb
View file @
2442d007
...
@@ -40,6 +40,7 @@ module Geo::ReplicableRegistry
...
@@ -40,6 +40,7 @@ module Geo::ReplicableRegistry
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:pending
,
->
{
with_state
(
:pending
)
}
scope
:pending
,
->
{
with_state
(
:pending
)
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retryable
,
->
{
failed
.
retry_due
}
scope
:ordered
,
->
{
order
(
:id
)
}
scope
:ordered
,
->
{
order
(
:id
)
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
...
...
ee/app/models/concerns/geo/syncable.rb
View file @
2442d007
...
@@ -4,9 +4,11 @@ module Geo::Syncable
...
@@ -4,9 +4,11 @@ module Geo::Syncable
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
scope
:failed
,
->
{
where
(
success:
false
)
}
scope
:failed
,
->
{
where
(
success:
false
).
where
.
not
(
retry_count:
nil
)
}
scope
:synced
,
->
{
where
(
success:
true
)
}
scope
:retry_due
,
->
{
where
(
'retry_at is NULL OR retry_at < ?'
,
Time
.
current
)
}
scope
:missing_on_primary
,
->
{
where
(
missing_on_primary:
true
)
}
scope
:missing_on_primary
,
->
{
where
(
missing_on_primary:
true
)
}
scope
:never_synced
,
->
{
where
(
success:
false
,
retry_count:
nil
)
}
scope
:retry_due
,
->
{
where
(
'retry_at is NULL OR retry_at < ?'
,
Time
.
current
)
}
scope
:retryable
,
->
{
failed
.
retry_due
}
scope
:synced
,
->
{
where
(
success:
true
)
}
end
end
end
end
ee/app/models/geo/base_registry.rb
View file @
2442d007
...
@@ -52,8 +52,7 @@ class Geo::BaseRegistry < Geo::TrackingBase
...
@@ -52,8 +52,7 @@ class Geo::BaseRegistry < Geo::TrackingBase
end
end
def
self
.
find_failed_registries
(
batch_size
:,
except_ids:
[])
def
self
.
find_failed_registries
(
batch_size
:,
except_ids:
[])
failed
retryable
.
retry_due
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
limit
(
batch_size
)
.
limit
(
batch_size
)
end
end
...
...
ee/app/models/geo/container_repository_registry.rb
View file @
2442d007
...
@@ -12,6 +12,7 @@ class Geo::ContainerRepositoryRegistry < Geo::BaseRegistry
...
@@ -12,6 +12,7 @@ class Geo::ContainerRepositoryRegistry < Geo::BaseRegistry
scope
:failed
,
->
{
with_state
(
:failed
)
}
scope
:failed
,
->
{
with_state
(
:failed
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retryable
,
->
{
failed
.
retry_due
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
state
:started
state
:started
...
...
ee/app/models/geo/design_registry.rb
View file @
2442d007
...
@@ -15,6 +15,7 @@ class Geo::DesignRegistry < Geo::BaseRegistry
...
@@ -15,6 +15,7 @@ class Geo::DesignRegistry < Geo::BaseRegistry
scope
:failed
,
->
{
with_state
(
:failed
)
}
scope
:failed
,
->
{
with_state
(
:failed
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:synced
,
->
{
with_state
(
:synced
)
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retry_due
,
->
{
where
(
arel_table
[
:retry_at
].
eq
(
nil
).
or
(
arel_table
[
:retry_at
].
lt
(
Time
.
current
)))
}
scope
:retryable
,
->
{
pending
.
or
(
failed
.
retry_due
)
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
state
:started
state
:started
...
@@ -75,10 +76,6 @@ class Geo::DesignRegistry < Geo::BaseRegistry
...
@@ -75,10 +76,6 @@ class Geo::DesignRegistry < Geo::BaseRegistry
designs_repositories
designs_repositories
end
end
def
self
.
updated_recently
pending
.
or
(
failed
.
retry_due
)
end
def
fail_sync!
(
message
,
error
,
attrs
=
{})
def
fail_sync!
(
message
,
error
,
attrs
=
{})
new_retry_count
=
retry_count
+
1
new_retry_count
=
retry_count
+
1
...
...
ee/app/models/geo/job_artifact_registry.rb
View file @
2442d007
...
@@ -6,12 +6,6 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry
...
@@ -6,12 +6,6 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry
MODEL_CLASS
=
::
Ci
::
JobArtifact
MODEL_CLASS
=
::
Ci
::
JobArtifact
MODEL_FOREIGN_KEY
=
:artifact_id
MODEL_FOREIGN_KEY
=
:artifact_id
scope
:never_synced
,
->
{
where
(
success:
false
,
retry_count:
nil
)
}
def
self
.
failed
where
(
success:
false
).
where
.
not
(
retry_count:
nil
)
end
def
self
.
finder_class
def
self
.
finder_class
::
Geo
::
JobArtifactRegistryFinder
::
Geo
::
JobArtifactRegistryFinder
end
end
...
...
ee/app/models/geo/lfs_object_registry.rb
View file @
2442d007
...
@@ -11,12 +11,6 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry
...
@@ -11,12 +11,6 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry
belongs_to
:lfs_object
,
class_name:
'LfsObject'
belongs_to
:lfs_object
,
class_name:
'LfsObject'
scope
:never_synced
,
->
{
where
(
success:
false
,
retry_count:
nil
)
}
def
self
.
failed
where
(
success:
false
).
where
.
not
(
retry_count:
nil
)
end
def
self
.
finder_class
def
self
.
finder_class
::
Geo
::
LfsObjectRegistryFinder
::
Geo
::
LfsObjectRegistryFinder
end
end
...
...
ee/app/models/geo/project_registry.rb
View file @
2442d007
...
@@ -21,8 +21,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
...
@@ -21,8 +21,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
validates
:project
,
presence:
true
,
uniqueness:
true
validates
:project
,
presence:
true
,
uniqueness:
true
scope
:never_synced
,
->
{
where
(
last_repository_synced_at:
nil
)
}
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
scope
:retryable
,
->
{
dirty
.
retry_due
}
scope
:never_synced
,
->
{
where
(
last_repository_synced_at:
nil
)
}
scope
:synced_repos
,
->
{
where
(
resync_repository:
false
)
}
scope
:synced_repos
,
->
{
where
(
resync_repository:
false
)
}
scope
:synced_wikis
,
->
{
where
(
resync_wiki:
false
)
}
scope
:synced_wikis
,
->
{
where
(
resync_wiki:
false
)
}
scope
:failed_repos
,
->
{
where
(
arel_table
[
:repository_retry_count
].
gt
(
0
))
}
scope
:failed_repos
,
->
{
where
(
arel_table
[
:repository_retry_count
].
gt
(
0
))
}
...
...
ee/app/models/geo/upload_registry.rb
View file @
2442d007
...
@@ -10,9 +10,7 @@ class Geo::UploadRegistry < Geo::BaseRegistry
...
@@ -10,9 +10,7 @@ class Geo::UploadRegistry < Geo::BaseRegistry
belongs_to
:upload
,
foreign_key: :file_id
belongs_to
:upload
,
foreign_key: :file_id
scope
:failed
,
->
{
where
(
success:
false
).
where
.
not
(
retry_count:
nil
)
}
scope
:fresh
,
->
{
order
(
created_at: :desc
)
}
scope
:fresh
,
->
{
order
(
created_at: :desc
)
}
scope
:never_synced
,
->
{
where
(
success:
false
,
retry_count:
nil
)
}
def
self
.
finder_class
def
self
.
finder_class
::
Geo
::
AttachmentRegistryFinder
::
Geo
::
AttachmentRegistryFinder
...
...
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