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
9d091555
Commit
9d091555
authored
Nov 24, 2021
by
Maxime Orefice
Committed by
Marius Bobin
Nov 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix database cross-join in ApplicationContext
parent
539197c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
7 deletions
+36
-7
lib/gitlab/application_context.rb
lib/gitlab/application_context.rb
+2
-5
spec/lib/gitlab/application_context_spec.rb
spec/lib/gitlab/application_context_spec.rb
+32
-0
spec/requests/api/ci/runner/jobs_request_post_spec.rb
spec/requests/api/ci/runner/jobs_request_post_spec.rb
+2
-2
No files found.
lib/gitlab/application_context.rb
View file @
9d091555
...
...
@@ -124,11 +124,8 @@ module Gitlab
strong_memoize
(
:runner_project
)
do
next
unless
runner
&
.
project_type?
projects
=
::
Gitlab
::
Database
.
allow_cross_joins_across_databases
(
url:
'https://gitlab.com/gitlab-org/gitlab/-/issues/342147'
)
do
runner
.
projects
.
take
(
2
)
# rubocop: disable CodeReuse/ActiveRecord
end
projects
.
first
if
projects
.
one?
runner_projects
=
runner
.
runner_projects
.
take
(
2
)
# rubocop: disable CodeReuse/ActiveRecord
runner_projects
.
first
.
project
if
runner_projects
.
one?
end
end
...
...
spec/lib/gitlab/application_context_spec.rb
View file @
9d091555
...
...
@@ -152,6 +152,38 @@ RSpec.describe Gitlab::ApplicationContext do
end
end
end
context
'when using a runner project'
do
let_it_be_with_reload
(
:runner
)
{
create
(
:ci_runner
,
:project
)
}
it
'sets project path from runner project'
do
context
=
described_class
.
new
(
runner:
runner
)
expect
(
result
(
context
)).
to
include
(
project:
runner
.
runner_projects
.
first
.
project
.
full_path
)
end
context
'when the runner serves multiple projects'
do
before
do
create
(
:ci_runner_project
,
runner:
runner
,
project:
create
(
:project
))
end
it
'does not set project path'
do
context
=
described_class
.
new
(
runner:
runner
)
expect
(
result
(
context
)).
to
include
(
project:
nil
)
end
end
end
context
'when using an instance runner'
do
let_it_be
(
:runner
)
{
create
(
:ci_runner
,
:instance
)
}
it
'does not sets project path'
do
context
=
described_class
.
new
(
runner:
runner
)
expect
(
result
(
context
)).
to
include
(
project:
nil
)
end
end
end
describe
'#use'
do
...
...
spec/requests/api/ci/runner/jobs_request_post_spec.rb
View file @
9d091555
...
...
@@ -833,8 +833,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
let
(
:expected_params
)
{
{
project:
project
.
full_path
,
client_id:
"runner/
#{
runner
.
id
}
"
}
}
end
it_behaves_like
'not executing any extra queries for the application context'
,
2
do
# Extra queries: Project, Route
it_behaves_like
'not executing any extra queries for the application context'
,
3
do
# Extra queries: Project, Route
, RunnerProject
let
(
:subject_proc
)
{
proc
{
request_job
}
}
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