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
c779c2ec
Commit
c779c2ec
authored
Jan 11, 2021
by
David Kim
Committed by
Mayra Cabrera
Jan 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid scheduling mirrors for pending_delete projects
parent
85596599
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
ee/app/models/ee/project_import_state.rb
ee/app/models/ee/project_import_state.rb
+8
-5
ee/app/workers/update_all_mirrors_worker.rb
ee/app/workers/update_all_mirrors_worker.rb
+1
-0
ee/changelogs/unreleased/avoid-mirroring-pending-delete-projects.yml
...gs/unreleased/avoid-mirroring-pending-delete-projects.yml
+5
-0
ee/spec/models/project_import_state_spec.rb
ee/spec/models/project_import_state_spec.rb
+17
-1
ee/spec/workers/update_all_mirrors_worker_spec.rb
ee/spec/workers/update_all_mirrors_worker_spec.rb
+14
-4
No files found.
ee/app/models/ee/project_import_state.rb
View file @
c779c2ec
...
...
@@ -9,7 +9,7 @@ module EE
BACKOFF_PERIOD
=
24
.
seconds
JITTER
=
6
.
seconds
delegate
:mirror?
,
to: :project
delegate
:mirror?
,
:mirror_with_content?
,
:archived
,
:pending_delete
,
to: :project
before_validation
:set_next_execution_to_now
,
on: :create
...
...
@@ -78,7 +78,7 @@ module EE
override
:in_progress?
def
in_progress?
# If we're importing while we do have a repository, we're simply updating the mirror.
super
&&
!
project
.
mirror_with_content?
super
&&
!
mirror_with_content?
end
def
mirror_waiting_duration
...
...
@@ -94,13 +94,12 @@ module EE
end
def
updating_mirror?
(
scheduled?
||
started?
)
&&
project
.
mirror_with_content?
(
scheduled?
||
started?
)
&&
mirror_with_content?
end
def
mirror_update_due?
return
false
unless
project
.
mirror_with_content
?
return
false
unless
project
_eligible_for_mirroring
?
return
false
unless
next_execution_timestamp?
return
false
if
project
.
archived?
return
false
if
hard_failed?
return
false
if
updating_mirror?
...
...
@@ -172,6 +171,10 @@ module EE
private
def
project_eligible_for_mirroring?
mirror_with_content?
&&
!
archived
&&
!
pending_delete
end
def
state_updated?
mirror?
&&
last_update_at
end
...
...
ee/app/workers/update_all_mirrors_worker.rb
View file @
c779c2ec
...
...
@@ -105,6 +105,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
def
pull_mirrors_batch
(
freeze_at
:,
batch_size
:,
offset_at:
nil
)
relation
=
Project
.
non_archived
.
without_deleted
.
mirrors_to_sync
(
freeze_at
)
.
reorder
(
'import_state.next_execution_timestamp'
)
.
limit
(
batch_size
)
...
...
ee/changelogs/unreleased/avoid-mirroring-pending-delete-projects.yml
0 → 100644
View file @
c779c2ec
---
title
:
Avoid scheduling mirrors for pending_delete projects
merge_request
:
50820
author
:
type
:
changed
ee/spec/models/project_import_state_spec.rb
View file @
c779c2ec
...
...
@@ -282,7 +282,7 @@ RSpec.describe ProjectImportState, type: :model do
end
before
do
import_state
.
project
.
update
!
(
archived:
true
)
import_state
.
project
.
update
_column
(
:archived
,
true
)
end
it
'returns false'
do
...
...
@@ -290,6 +290,22 @@ RSpec.describe ProjectImportState, type: :model do
end
end
context
'when the project pending_delete'
do
let
(
:import_state
)
do
create
(
:import_state
,
:finished
,
:mirror
,
:repository
,
next_execution_timestamp:
Time
.
current
-
2
.
minutes
)
end
it
'returns false'
do
import_state
.
project
.
update_column
(
:pending_delete
,
true
)
expect
(
import_state
.
mirror_update_due?
).
to
be
false
end
end
context
'when mirror has no content'
do
it
'returns false'
do
import_state
=
create
(
:import_state
,
:finished
,
:mirror
)
...
...
ee/spec/workers/update_all_mirrors_worker_spec.rb
View file @
c779c2ec
...
...
@@ -141,7 +141,7 @@ RSpec.describe UpdateAllMirrorsWorker do
context
'when the instance is licensed'
do
def
scheduled_mirror
(
at
:)
project
=
create
(
:project
,
:mirror
)
project
.
import_state
.
update
!
(
next_execution_timestamp:
at
)
project
.
import_state
.
update
_column
(
:next_execution_timestamp
,
at
)
project
end
...
...
@@ -165,8 +165,8 @@ RSpec.describe UpdateAllMirrorsWorker do
create
(
:gitlab_subscription
,
(
licensed
?
:bronze
:
:free
),
namespace:
namespace
.
root_ancestor
)
project
.
import_state
.
update
!
(
next_execution_timestamp:
at
)
project
.
update
!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
unless
public
project
.
import_state
.
update
_column
(
:next_execution_timestamp
,
at
)
project
.
update
_column
(
:visibility_level
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)
unless
public
project
end
...
...
@@ -232,7 +232,17 @@ RSpec.describe UpdateAllMirrorsWorker do
end
it
"does not schedule a mirror of an archived project"
do
licensed_project1
.
update!
(
archived:
true
)
licensed_project1
.
update_column
(
:archived
,
true
)
schedule_mirrors!
(
capacity:
4
)
expect_import_scheduled
(
licensed_project2
,
public_project
)
expect_import_not_scheduled
(
licensed_project1
)
expect_import_not_scheduled
(
*
unlicensed_projects
)
end
it
"does not schedule a mirror of an pending_delete project"
do
licensed_project1
.
update_column
(
:pending_delete
,
true
)
schedule_mirrors!
(
capacity:
4
)
...
...
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