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
...
@@ -47,26 +47,15 @@ module Geo
end
end
def
find_container_repository_ids_not_synced
(
batch_size
:)
def
find_container_repository_ids_not_synced
(
batch_size
:)
if
Geo
::
ContainerRepositoryRegistry
.
registry_consistency_worker_enabled?
registry_finder
registry_finder
.
find_never_synced_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
find_never_synced_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
.
pluck_model_foreign_key
else
registry_finder
.
find_unsynced
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_primary_key
end
end
end
def
find_retryable_container_registry_ids
(
batch_size
:)
def
find_retryable_container_registry_ids
(
batch_size
:)
if
Geo
::
ContainerRepositoryRegistry
.
registry_consistency_worker_enabled?
registry_finder
registry_finder
.
find_retryable_dirty_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
find_retryable_dirty_registries
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
.
pluck_model_foreign_key
.
pluck_model_foreign_key
else
registry_finder
.
find_retryable_failed_ids
(
batch_size:
batch_size
,
except_ids:
scheduled_repository_ids
)
end
end
end
def
registry_finder
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_
...
@@ -6,8 +6,8 @@ RSpec.describe Geo::ContainerRepositorySyncDispatchWorker, :geo, :use_sql_query_
include
::
EE
::
GeoHelpers
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
include
ExclusiveLeaseHelpers
let
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let
_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
before
do
stub_current_geo_node
(
secondary
)
stub_current_geo_node
(
secondary
)
...
@@ -49,149 +49,60 @@ RSpec.describe Geo::ContainerRepositorySyncDispatchWorker, :geo, :use_sql_query_
...
@@ -49,149 +49,60 @@ RSpec.describe Geo::ContainerRepositorySyncDispatchWorker, :geo, :use_sql_query_
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
end
end
context
'when geo_container_registry_ssot_sync is disabled'
,
:geo_fdw
do
it
'performs Geo::ContainerRepositorySyncWorker'
do
before
do
registry
=
create
(
:container_repository_registry
)
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
)
subject
.
perform
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
).
with
(
registry
.
container_repository_id
)
end
it
'retries failed files when retry_at is in the past'
do
subject
.
perform
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
yesterday
)
end
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
it
'performs Geo::ContainerRepositorySyncWorker for failed syncs'
do
end
registry
=
create
(
:container_repository_registry
,
:sync_failed
)
end
context
'when node has namespace restrictions'
,
:request_store
do
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
)
let
(
:synced_group
)
{
create
(
:group
)
}
.
with
(
registry
.
container_repository_id
).
once
.
and_return
(
spy
)
let
(
:project_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:unsynced_project
)
{
create
(
:project
)
}
before
do
subject
.
perform
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
end
end
it
'does not perform Geo::ContainerRepositorySyncWorker for repositories that does not belong to selected namespaces'
do
it
'does not perform Geo::ContainerRepositorySyncWorker for synced repositories'
do
container_repository
=
create
(
:container_repository
,
project:
project_in_synced_group
)
create
(
:container_repository_registry
,
:synced
)
create
(
:container_repository
,
project:
unsynced_project
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
to
receive
(
:perform_async
)
expect
(
Geo
::
ContainerRepositorySyncWorker
).
not_to
receive
(
:perform_async
)
.
with
(
container_repository
.
id
).
once
.
and_return
(
spy
)
subject
.
perform
subject
.
perform
end
end
end
end
context
'w
hen geo_container_registry_ssot_sync is enabled
'
do
context
'w
ith a failed sync
'
do
before
do
it
'does not stall backfill'
do
stub_feature_flags
(
geo_container_registry_ssot_sync:
true
)
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
)
end
unsynced_registry
=
create
(
:container_repository_registry
)
it
'performs Geo::ContainerRepositorySyncWorker'
do
stub_const
(
'Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE'
,
1
)
registry
=
create
(
:container_repository_registry
)
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
subject
.
perform
end
end
it
'
performs Geo::ContainerRepositorySyncWorker for failed syncs
'
do
it
'
does not retry failed files when retry_at is tomorrow
'
do
registry
=
create
(
:container_repository_registry
,
:sync_failed
)
failed_registry
=
create
(
:container_repository_registry
,
:sync_failed
,
retry_at:
Date
.
tomorrow
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
to
receive
(
:perform_async
)
expect
(
Geo
::
ContainerRepositorySyncWorker
)
.
with
(
registry
.
container_repository_id
).
once
.
and_return
(
spy
)
.
not_to
receive
(
:perform_async
).
with
(
failed_registry
.
container_repository_id
)
subject
.
perform
subject
.
perform
end
end
it
'
does not perform Geo::ContainerRepositorySyncWorker for synced repositories
'
do
it
'
retries failed files when retry_at is in the past
'
do
create
(
:container_repository_registry
,
:synced
)
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
subject
.
perform
end
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
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