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
Jérome Perrin
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
Show 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
Sidekiq
::
Worker
include
CronjobQueue
include
CronjobQueue
...
...
config/gitlab.yml.example
View file @
4d4e99a2
...
@@ -177,8 +177,8 @@ production: &base
...
@@ -177,8 +177,8 @@ production: &base
# Periodically executed jobs, to self-heal Gitlab, do external synchronizations, etc.
# 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
# Please read here for more information: https://github.com/ondrejbartas/sidekiq-cron#adding-cron-job
cron_jobs:
cron_jobs:
# Flag stuck CI
build
s as failed
# Flag stuck CI
job
s as failed
stuck_ci_
build
s_worker:
stuck_ci_
job
s_worker:
cron: "0 * * * *"
cron: "0 * * * *"
# Remove expired build artifacts
# Remove expired build artifacts
expire_build_artifacts_worker:
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[
...
@@ -308,9 +308,9 @@ Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar[
# Cron Jobs
# Cron Jobs
#
#
Settings
[
'cron_jobs'
]
||=
Settingslogic
.
new
({})
Settings
[
'cron_jobs'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
build
s_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
job
s_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_
build
s_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'stuck_ci_
job
s_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'stuck_ci_
builds_worker'
][
'job_class'
]
=
'StuckCiBuild
sWorker'
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'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
][
'cron'
]
||=
'50 * * * *'
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
][
'cron'
]
||=
'50 * * * *'
Settings
.
cron_jobs
[
'expire_build_artifacts_worker'
][
'job_class'
]
=
'ExpireBuildArtifactsWorker'
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'
require
'spec_helper'
describe
StuckCi
Build
sWorker
do
describe
StuckCi
Job
sWorker
do
let!
(
:runner
)
{
create
:ci_runner
}
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
(
:worker
)
{
described_class
.
new
}
let
(
:exclusive_lease_uuid
)
{
SecureRandom
.
uuid
}
let
(
:exclusive_lease_uuid
)
{
SecureRandom
.
uuid
}
subject
do
subject
do
build
.
reload
job
.
reload
build
.
status
job
.
status
end
end
before
do
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
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
exclusive_lease_uuid
)
end
end
shared_examples
'
build
is dropped'
do
shared_examples
'
job
is dropped'
do
it
'changes status'
do
it
'changes status'
do
worker
.
perform
worker
.
perform
is_expected
.
to
eq
(
'failed'
)
is_expected
.
to
eq
(
'failed'
)
end
end
end
end
shared_examples
'
build
is unchanged'
do
shared_examples
'
job
is unchanged'
do
it
"doesn't change status"
do
it
"doesn't change status"
do
worker
.
perform
worker
.
perform
is_expected
.
to
eq
(
status
)
is_expected
.
to
eq
(
status
)
end
end
end
end
context
'when
build
is pending'
do
context
'when
job
is pending'
do
let
(
:status
)
{
'pending'
}
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
)
}
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
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
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
}
let
(
:updated_at
)
{
6
.
hours
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
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
}
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
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
)
}
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
}
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
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
}
let
(
:updated_at
)
{
30
.
minutes
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
end
end
end
end
context
'when
build
is running'
do
context
'when
job
is running'
do
let
(
:status
)
{
'running'
}
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
}
let
(
:updated_at
)
{
2
.
hours
.
ago
}
it_behaves_like
'
build
is dropped'
it_behaves_like
'
job
is dropped'
end
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
}
let
(
:updated_at
)
{
30
.
minutes
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
end
end
%w(success skipped failed canceled)
.
each
do
|
status
|
%w(success skipped failed canceled)
.
each
do
|
status
|
context
"when
build
is
#{
status
}
"
do
context
"when
job
is
#{
status
}
"
do
let
(
:status
)
{
status
}
let
(
:status
)
{
status
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
it_behaves_like
'
build
is unchanged'
it_behaves_like
'
job
is unchanged'
end
end
end
end
...
@@ -93,9 +93,9 @@ describe StuckCiBuildsWorker do
...
@@ -93,9 +93,9 @@ describe StuckCiBuildsWorker do
let
(
:status
)
{
'running'
}
let
(
:status
)
{
'running'
}
let
(
:updated_at
)
{
2
.
days
.
ago
}
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
)
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:drop
)
worker
.
perform
worker
.
perform
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