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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
4d4e99a2
Commit
4d4e99a2
authored
Mar 03, 2017
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renable StuckCiBuildsWorker to StucjCiJobsWorker
parent
b66fe22a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
35 deletions
+35
-35
app/workers/stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+1
-1
config/gitlab.yml.example
config/gitlab.yml.example
+2
-2
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+3
-3
spec/workers/stuck_ci_jobs_worker_spec.rb
spec/workers/stuck_ci_jobs_worker_spec.rb
+29
-29
No files found.
app/workers/stuck_ci_
build
s_worker.rb
→
app/workers/stuck_ci_
job
s_worker.rb
View file @
4d4e99a2
class
StuckCi
Build
sWorker
class
StuckCi
Job
sWorker
include
Sidekiq
::
Worker
include
CronjobQueue
...
...
config/gitlab.yml.example
View file @
4d4e99a2
...
...
@@ -177,8 +177,8 @@ production: &base
# Periodically executed jobs, to self-heal Gitlab, do external synchronizations, etc.
# Please read here for more information: https://github.com/ondrejbartas/sidekiq-cron#adding-cron-job
cron_jobs:
# Flag stuck CI
build
s as failed
stuck_ci_
build
s_worker:
# Flag stuck CI
job
s as failed
stuck_ci_
job
s_worker:
cron: "0 * * * *"
# Remove expired build artifacts
expire_build_artifacts_worker:
...
...
config/initializers/1_settings.rb
View file @
4d4e99a2
...
...
@@ -308,9 +308,9 @@ Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar[
# Cron Jobs
#
Settings
[
'cron_jobs'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
build
s_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
build
s_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'stuck_ci_
builds_worker'
][
'job_class'
]
=
'StuckCiBuild
sWorker'
Settings
.
cron_jobs
[
'stuck_ci_
job
s_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
job
s_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'stuck_ci_
jobs_worker'
][
'job_class'
]
=
'StuckCiJob
sWorker'
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
][
'cron'
]
||=
'50 * * * *'
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
][
'job_class'
]
=
'ExpireBuildArtifactsWorker'
...
...
spec/workers/stuck_ci_
build
s_worker_spec.rb
→
spec/workers/stuck_ci_
job
s_worker_spec.rb
View file @
4d4e99a2
require
'spec_helper'
describe
StuckCi
Build
sWorker
do
describe
StuckCi
Job
sWorker
do
let!
(
:runner
)
{
create
:ci_runner
}
let!
(
:
build
)
{
create
:ci_build
,
runner:
runner
}
let!
(
:
job
)
{
create
:ci_build
,
runner:
runner
}
let
(
:worker
)
{
described_class
.
new
}
let
(
:exclusive_lease_uuid
)
{
SecureRandom
.
uuid
}
subject
do
build
.
reload
build
.
status
job
.
reload
job
.
status
end
before
do
build
.
update!
(
status:
status
,
updated_at:
updated_at
)
job
.
update!
(
status:
status
,
updated_at:
updated_at
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
exclusive_lease_uuid
)
end
shared_examples
'
build
is dropped'
do
shared_examples
'
job
is dropped'
do
it
'changes status'
do
worker
.
perform
is_expected
.
to
eq
(
'failed'
)
end
end
shared_examples
'
build
is unchanged'
do
shared_examples
'
job
is unchanged'
do
it
"doesn't change status"
do
worker
.
perform
is_expected
.
to
eq
(
status
)
end
end
context
'when
build
is pending'
do
context
'when
job
is pending'
do
let
(
:status
)
{
'pending'
}
context
'when
build
is not stuck'
do
context
'when
job
is not stuck'
do
before
{
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:stuck?
).
and_return
(
false
)
}
context
'when
build
was not updated for more than 1 day ago'
do
context
'when
job
was not updated for more than 1 day ago'
do
let
(
:updated_at
)
{
2
.
days
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
context
'when
build
was updated in less than 1 day ago'
do
context
'when
job
was updated in less than 1 day ago'
do
let
(
:updated_at
)
{
6
.
hours
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
context
'when
build
was not updated for more than 1 hour ago'
do
context
'when
job
was not updated for more than 1 hour ago'
do
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
context
'when
build
is stuck'
do
context
'when
job
is stuck'
do
before
{
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:stuck?
).
and_return
(
true
)
}
context
'when
build
was not updated for more than 1 hour ago'
do
context
'when
job
was not updated for more than 1 hour ago'
do
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
context
'when
build
was updated in less than 1 hour ago'
do
context
'when
job
was updated in less than 1 hour ago'
do
let
(
:updated_at
)
{
30
.
minutes
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
end
context
'when
build
is running'
do
context
'when
job
is running'
do
let
(
:status
)
{
'running'
}
context
'when
build
was not updated for more than 1 hour ago'
do
context
'when
job
was not updated for more than 1 hour ago'
do
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
context
'when
build
was updated in less than 1 hour ago'
do
context
'when
job
was updated in less than 1 hour ago'
do
let
(
:updated_at
)
{
30
.
minutes
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
%w(success skipped failed canceled)
.
each
do
|
status
|
context
"when
build
is
#{
status
}
"
do
context
"when
job
is
#{
status
}
"
do
let
(
:status
)
{
status
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
...
...
@@ -93,9 +93,9 @@ describe StuckCiBuildsWorker do
let
(
:status
)
{
'running'
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
before
{
build
.
project
.
update
(
pending_delete:
true
)
}
before
{
job
.
project
.
update
(
pending_delete:
true
)
}
it
'does not drop
build
'
do
it
'does not drop
job
'
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:drop
)
worker
.
perform
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