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
e610f960
Commit
e610f960
authored
Oct 03, 2017
by
Tiago Botelho
Committed by
Douwe Maan
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds scheduled import jobs to the stuck import jobs detection worker.
parent
58a312f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
app/workers/stuck_import_jobs_worker.rb
app/workers/stuck_import_jobs_worker.rb
+8
-8
changelogs/unreleased-ee/mark-scheduled-mirrors-as-stuck.yml
changelogs/unreleased-ee/mark-scheduled-mirrors-as-stuck.yml
+5
-0
spec/workers/stuck_import_jobs_worker_spec.rb
spec/workers/stuck_import_jobs_worker_spec.rb
+13
-3
No files found.
app/workers/stuck_import_jobs_worker.rb
View file @
e610f960
...
@@ -16,7 +16,7 @@ class StuckImportJobsWorker
...
@@ -16,7 +16,7 @@ class StuckImportJobsWorker
private
private
def
mark_projects_without_jid_as_failed!
def
mark_projects_without_jid_as_failed!
start
ed_projects_without_jid
.
each
do
|
project
|
enqueu
ed_projects_without_jid
.
each
do
|
project
|
project
.
mark_import_as_failed
(
error_message
)
project
.
mark_import_as_failed
(
error_message
)
end
.
count
end
.
count
end
end
...
@@ -24,7 +24,7 @@ class StuckImportJobsWorker
...
@@ -24,7 +24,7 @@ class StuckImportJobsWorker
def
mark_projects_with_jid_as_failed!
def
mark_projects_with_jid_as_failed!
completed_jids_count
=
0
completed_jids_count
=
0
start
ed_projects_with_jid
.
find_in_batches
(
batch_size:
500
)
do
|
group
|
enqueu
ed_projects_with_jid
.
find_in_batches
(
batch_size:
500
)
do
|
group
|
jids
=
group
.
map
(
&
:import_jid
)
jids
=
group
.
map
(
&
:import_jid
)
# Find the jobs that aren't currently running or that exceeded the threshold.
# Find the jobs that aren't currently running or that exceeded the threshold.
...
@@ -43,16 +43,16 @@ class StuckImportJobsWorker
...
@@ -43,16 +43,16 @@ class StuckImportJobsWorker
completed_jids_count
completed_jids_count
end
end
def
start
ed_projects
def
enqueu
ed_projects
Project
.
with_import_status
(
:started
)
Project
.
with_import_status
(
:s
cheduled
,
:s
tarted
)
end
end
def
start
ed_projects_with_jid
def
enqueu
ed_projects_with_jid
start
ed_projects
.
where
.
not
(
import_jid:
nil
)
enqueu
ed_projects
.
where
.
not
(
import_jid:
nil
)
end
end
def
start
ed_projects_without_jid
def
enqueu
ed_projects_without_jid
start
ed_projects
.
where
(
import_jid:
nil
)
enqueu
ed_projects
.
where
(
import_jid:
nil
)
end
end
def
error_message
def
error_message
...
...
changelogs/unreleased-ee/mark-scheduled-mirrors-as-stuck.yml
0 → 100644
View file @
e610f960
---
title
:
Find stuck scheduled import jobs and also mark them as failed.
merge_request
:
3055
author
:
type
:
fixed
spec/workers/stuck_import_jobs_worker_spec.rb
View file @
e610f960
...
@@ -8,9 +8,7 @@ describe StuckImportJobsWorker do
...
@@ -8,9 +8,7 @@ describe StuckImportJobsWorker do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
exclusive_lease_uuid
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
exclusive_lease_uuid
)
end
end
describe
'with started import_status'
do
shared_examples
'project import job detection'
do
let
(
:project
)
{
create
(
:project
,
:import_started
,
import_jid:
'123'
)
}
describe
'long running import'
do
describe
'long running import'
do
it
'marks the project as failed'
do
it
'marks the project as failed'
do
allow
(
Gitlab
::
SidekiqStatus
).
to
receive
(
:completed_jids
).
and_return
([
'123'
])
allow
(
Gitlab
::
SidekiqStatus
).
to
receive
(
:completed_jids
).
and_return
([
'123'
])
...
@@ -33,4 +31,16 @@ describe StuckImportJobsWorker do
...
@@ -33,4 +31,16 @@ describe StuckImportJobsWorker do
end
end
end
end
end
end
describe
'with scheduled import_status'
do
it_behaves_like
'project import job detection'
do
let
(
:project
)
{
create
(
:project
,
:import_scheduled
,
import_jid:
'123'
)
}
end
end
describe
'with started import_status'
do
it_behaves_like
'project import job detection'
do
let
(
:project
)
{
create
(
:project
,
:import_started
,
import_jid:
'123'
)
}
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