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
7357021e
Commit
7357021e
authored
May 27, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move LB sticking for CI build to Core
parent
064e9d3c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
22 deletions
+23
-22
app/models/ci/build.rb
app/models/ci/build.rb
+9
-0
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+0
-8
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+0
-14
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+14
-0
No files found.
app/models/ci/build.rb
View file @
7357021e
...
@@ -214,6 +214,8 @@ module Ci
...
@@ -214,6 +214,8 @@ module Ci
before_save
:ensure_token
before_save
:ensure_token
before_destroy
{
unscoped_project
}
before_destroy
{
unscoped_project
}
after_save
:stick_build_if_status_changed
after_create
unless: :importing?
do
|
build
|
after_create
unless: :importing?
do
|
build
|
run_after_commit
{
BuildHooksWorker
.
perform_async
(
build
.
id
)
}
run_after_commit
{
BuildHooksWorker
.
perform_async
(
build
.
id
)
}
end
end
...
@@ -1082,6 +1084,13 @@ module Ci
...
@@ -1082,6 +1084,13 @@ module Ci
private
private
def
stick_build_if_status_changed
return
unless
saved_change_to_status?
return
unless
running?
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick
(
:build
,
id
)
end
def
status_commit_hooks
def
status_commit_hooks
@status_commit_hooks
||=
[]
@status_commit_hooks
||=
[]
end
end
...
...
ee/app/models/ee/ci/build.rb
View file @
7357021e
...
@@ -31,7 +31,6 @@ module EE
...
@@ -31,7 +31,6 @@ module EE
has_many
:security_scans
,
class_name:
'Security::Scan'
has_many
:security_scans
,
class_name:
'Security::Scan'
after_save
:stick_build_if_status_changed
after_commit
:track_ci_secrets_management_usage
,
on: :create
after_commit
:track_ci_secrets_management_usage
,
on: :create
delegate
:service_specification
,
to: :runner_session
,
allow_nil:
true
delegate
:service_specification
,
to: :runner_session
,
allow_nil:
true
...
@@ -62,13 +61,6 @@ module EE
...
@@ -62,13 +61,6 @@ module EE
project
.
shared_runners_minutes_limit_enabled?
&&
runner
&
.
minutes_cost_factor
(
project
.
visibility_level
)
&
.
positive?
project
.
shared_runners_minutes_limit_enabled?
&&
runner
&
.
minutes_cost_factor
(
project
.
visibility_level
)
&
.
positive?
end
end
def
stick_build_if_status_changed
return
unless
saved_change_to_status?
return
unless
running?
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick
(
:build
,
id
)
end
def
log_geo_deleted_event
def
log_geo_deleted_event
# It is not needed to generate a Geo deleted event
# It is not needed to generate a Geo deleted event
# since Legacy Artifacts are migrated to multi-build artifacts
# since Legacy Artifacts are migrated to multi-build artifacts
...
...
ee/spec/models/ci/build_spec.rb
View file @
7357021e
...
@@ -107,20 +107,6 @@ RSpec.describe Ci::Build do
...
@@ -107,20 +107,6 @@ RSpec.describe Ci::Build do
end
end
end
end
describe
'#stick_build_if_status_changed'
do
it
'sticks the build if the status changed'
do
job
=
create
(
:ci_build
,
:pending
)
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:stick
)
.
with
(
:build
,
job
.
id
)
job
.
update!
(
status: :running
)
end
end
describe
'#variables'
do
describe
'#variables'
do
subject
{
job
.
variables
}
subject
{
job
.
variables
}
...
...
spec/models/ci/build_spec.rb
View file @
7357021e
...
@@ -320,6 +320,20 @@ RSpec.describe Ci::Build do
...
@@ -320,6 +320,20 @@ RSpec.describe Ci::Build do
end
end
end
end
describe
'#stick_build_if_status_changed'
do
it
'sticks the build if the status changed'
do
job
=
create
(
:ci_build
,
:pending
)
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:stick
)
.
with
(
:build
,
job
.
id
)
job
.
update!
(
status: :running
)
end
end
describe
'#enqueue'
do
describe
'#enqueue'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
...
...
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