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
e60ca686
Commit
e60ca686
authored
Jul 30, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove feature flag from container repository scheduler worker
parent
0ad5501e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
138 deletions
+38
-138
ee/app/workers/geo/container_repository_sync_dispatch_worker.rb
.../workers/geo/container_repository_sync_dispatch_worker.rb
+6
-17
ee/spec/workers/geo/container_repository_sync_dispatch_worker_spec.rb
...ers/geo/container_repository_sync_dispatch_worker_spec.rb
+32
-121
No files found.
ee/app/workers/geo/container_repository_sync_dispatch_worker.rb
View file @
e60ca686
...
...
@@ -47,26 +47,15 @@ module Geo
end
def
find_container_repository_ids_not_synced
(
batch_size
:)
if
Geo
::
ContainerRepositoryRegistry
.
registry_consistency_worker_enabled?
registry_finder
.
find_never_synced_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
else
registry_finder
.
find_unsynced
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_primary_key
end
registry_finder
.
find_never_synced_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
end
def
find_retryable_container_registry_ids
(
batch_size
:)
if
Geo
::
ContainerRepositoryRegistry
.
registry_consistency_worker_enabled?
registry_finder
.
find_retryable_dirty_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
else
registry_finder
.
find_retryable_failed_ids
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
end
registry_finder
.
find_retryable_dirty_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
end
def
registry_finder
...
...
ee/spec/workers/geo/container_repository_sync_dispatch_worker_spec.rb
View file @
e60ca686
...
...
@@ -6,8 +6,8 @@ RSpec.describe Geo::ContainerRepositorySyncDispatchWorker, :geo, :use_sql_query_
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
let
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let
_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
stub_current_geo_node
(
secondary
)
...
...
@@ -49,149 +49,60 @@ RSpec.describe Geo::ContainerRepositorySyncDispatchWorker, :geo, :use_sql_query_
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
end
context
'when geo_container_registry_ssot_sync is disabled'
,
:geo_fdw
do
before
do
stub_feature_flags
(
geo_container_registry_ssot_sync:
false
)
end
it
'performs Geo::ContainerRepositorySyncWorker'
do
container_repository
=
create
(
:container_repository
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
container_repository
.
id
)
subject
.
perform
end
it
'performs Geo::ContainerRepositorySyncWorker for failed syncs'
do
registry
=
create
(
:container_repository_registry
,
:sync_failed
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
)
.
with
(
registry
.
container_repository_id
).
once
.
and_return
(
spy
)
subject
.
perform
end
it
'does not perform Geo::ContainerRepositorySyncWorker for synced repositories'
do
create
(
:container_repository_registry
,
:synced
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
subject
.
perform
end
context
'with a failed sync'
do
it
'does not stall backfill'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
)
unsynced_container_repository
=
create
(
:container_repository
)
stub_const
(
'Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE'
,
1
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
unsynced_container_repository
.
id
)
subject
.
perform
end
it
'does not retry failed files when retry_at is tomorrow'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
tomorrow
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
it
'performs Geo::ContainerRepositorySyncWorker'
do
registry
=
create
(
:container_repository_registry
)
subject
.
perform
end
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
registry
.
container_repository_id
)
it
'retries failed files when retry_at is in the past'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
yesterday
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
end
subject
.
perform
end
end
it
'performs Geo::ContainerRepositorySyncWorker for failed syncs'
do
registry
=
create
(
:container_repository_registry
,
:sync_failed
)
context
'when node has namespace restrictions'
,
:request_store
do
let
(
:synced_group
)
{
create
(
:group
)
}
let
(
:project_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:unsynced_project
)
{
create
(
:project
)
}
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
)
.
with
(
registry
.
container_repository_id
).
once
.
and_return
(
spy
)
before
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
end
subject
.
perform
end
it
'does not perform Geo::ContainerRepositorySyncWorker for repositories that does not belong to selected namespaces'
do
container_repository
=
create
(
:container_repository
,
project:
project_in_synced_group
)
create
(
:container_repository
,
project:
unsynced_project
)
it
'does not perform Geo::ContainerRepositorySyncWorker for synced repositories'
do
create
(
:container_repository_registry
,
:synced
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
)
.
with
(
container_repository
.
id
).
once
.
and_return
(
spy
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
subject
.
perform
end
end
subject
.
perform
end
context
'w
hen geo_container_registry_ssot_sync is enabled
'
do
before
do
stub_feature_flags
(
geo_container_registry_ssot_sync:
true
)
end
context
'w
ith a failed sync
'
do
it
'does not stall backfill'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
)
unsynced_registry
=
create
(
:container_repository_registry
)
it
'performs Geo::ContainerRepositorySyncWorker'
do
registry
=
create
(
:container_repository_registry
)
stub_const
(
'Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE'
,
1
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
registry
.
container_repository_id
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
unsynced_registry
.
container_repository_id
)
subject
.
perform
end
it
'
performs Geo::ContainerRepositorySyncWorker for failed syncs
'
do
registry
=
create
(
:container_repository_registry
,
:sync_failed
)
it
'
does not retry failed files when retry_at is tomorrow
'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
tomorrow
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
)
.
with
(
registry
.
container_repository_id
).
once
.
and_return
(
spy
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
end
it
'
does not perform Geo::ContainerRepositorySyncWorker for synced repositories
'
do
create
(
:container_repository_registry
,
:synced
)
it
'
retries failed files when retry_at is in the past
'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
yesterday
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
end
context
'with a failed sync'
do
it
'does not stall backfill'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
)
unsynced_registry
=
create
(
:container_repository_registry
)
stub_const
(
'Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE'
,
1
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
unsynced_registry
.
container_repository_id
)
subject
.
perform
end
it
'does not retry failed files when retry_at is tomorrow'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
tomorrow
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
end
it
'retries failed files when retry_at is in the past'
do
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
yesterday
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
end
end
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