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
8d2758e0
Commit
8d2758e0
authored
Oct 21, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup stuck CI builds daily
parent
fb2f8be4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
CHANGELOG
CHANGELOG
+1
-0
app/workers/stuck_ci_builds_worker.rb
app/workers/stuck_ci_builds_worker.rb
+18
-0
spec/workers/stuck_ci_builds_worker_spec.rb
spec/workers/stuck_ci_builds_worker_spec.rb
+44
-0
No files found.
CHANGELOG
View file @
8d2758e0
...
@@ -35,6 +35,7 @@ v 8.1.0
...
@@ -35,6 +35,7 @@ v 8.1.0
- Fix duplicate repositories in GitHub import page (Stan Hu)
- Fix duplicate repositories in GitHub import page (Stan Hu)
- Redirect to a default path if HTTP_REFERER is not set (Stan Hu)
- Redirect to a default path if HTTP_REFERER is not set (Stan Hu)
- Adds ability to create directories using the web editor (Ben Ford)
- Adds ability to create directories using the web editor (Ben Ford)
- Cleanup stuck CI builds
v 8.1.0 (unreleased)
v 8.1.0 (unreleased)
- Send an email to admin email when a user is reported for spam (Jonathan Rochkind)
- Send an email to admin email when a user is reported for spam (Jonathan Rochkind)
...
...
app/workers/stuck_ci_builds_worker.rb
0 → 100644
View file @
8d2758e0
class
StuckCiBuildsWorker
include
Sidekiq
::
Worker
include
Sidetiq
::
Schedulable
BUILD_STUCK_TIMEOUT
=
1
.
day
recurrence
{
daily
}
def
perform
Rails
.
logger
.
info
'Cleaning stuck builds'
builds
=
Ci
::
Build
.
running_or_pending
.
where
(
'updated_at < ?'
,
BUILD_STUCK_TIMEOUT
.
ago
)
builds
.
find_each
(
batch_size:
50
).
each
do
|
build
|
Rails
.
logger
.
debug
"Dropping stuck
#{
build
.
status
}
build
#{
build
.
id
}
for runner
#{
build
.
runner_id
}
"
build
.
drop
end
end
end
spec/workers/stuck_ci_builds_worker_spec.rb
0 → 100644
View file @
8d2758e0
require
"spec_helper"
describe
StuckCiBuildsWorker
do
let!
(
:build
)
{
create
:ci_build
}
subject
do
build
.
reload
build
.
status
end
%w(pending running)
.
each
do
|
status
|
context
"
#{
status
}
build"
do
before
do
build
.
update!
(
status:
status
)
end
it
'gets dropped if it was updated over 2 days ago'
do
build
.
update!
(
updated_at:
2
.
day
.
ago
)
StuckCiBuildsWorker
.
new
.
perform
is_expected
.
to
eq
(
'failed'
)
end
it
"is still
#{
status
}
"
do
build
.
update!
(
updated_at:
1
.
minute
.
ago
)
StuckCiBuildsWorker
.
new
.
perform
is_expected
.
to
eq
(
status
)
end
end
end
%w(success failed canceled)
.
each
do
|
status
|
context
"
#{
status
}
build"
do
before
do
build
.
update!
(
status:
status
)
end
it
"is still
#{
status
}
"
do
build
.
update!
(
updated_at:
2
.
day
.
ago
)
StuckCiBuildsWorker
.
new
.
perform
is_expected
.
to
eq
(
status
)
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