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
251420dc
Commit
251420dc
authored
Dec 08, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capture job executor value in ci_runners table
Changelog: added
parent
70a1dc76
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
6 deletions
+70
-6
app/models/ci/runner.rb
app/models/ci/runner.rb
+32
-2
db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb
.../20211208111425_add_executor_type_column_to_ci_runners.rb
+7
-0
db/schema_migrations/20211208111425
db/schema_migrations/20211208111425
+1
-0
db/structure.sql
db/structure.sql
+2
-1
lib/api/ci/helpers/runner.rb
lib/api/ci/helpers/runner.rb
+1
-1
spec/lib/api/ci/helpers/runner_helpers_spec.rb
spec/lib/api/ci/helpers/runner_helpers_spec.rb
+4
-1
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+23
-1
No files found.
app/models/ci/runner.rb
View file @
251420dc
...
@@ -26,6 +26,21 @@ module Ci
...
@@ -26,6 +26,21 @@ module Ci
project_type:
3
project_type:
3
}
}
enum
executor_type:
{
unknown:
0
,
custom:
1
,
shell:
2
,
docker:
3
,
docker_windows:
4
,
docker_ssh:
5
,
ssh:
6
,
parallels:
7
,
virtualbox:
8
,
docker_machine:
9
,
docker_ssh_machine:
10
,
kubernetes:
11
},
_suffix:
true
# This `ONLINE_CONTACT_TIMEOUT` needs to be larger than
# This `ONLINE_CONTACT_TIMEOUT` needs to be larger than
# `RUNNER_QUEUE_EXPIRY_TIME+UPDATE_CONTACT_COLUMN_EVERY`
# `RUNNER_QUEUE_EXPIRY_TIME+UPDATE_CONTACT_COLUMN_EVERY`
#
#
...
@@ -152,7 +167,7 @@ module Ci
...
@@ -152,7 +167,7 @@ module Ci
after_destroy
:cleanup_runner_queue
after_destroy
:cleanup_runner_queue
cached_attr_reader
:version
,
:revision
,
:platform
,
:architecture
,
:ip_address
,
:contacted_at
cached_attr_reader
:version
,
:revision
,
:platform
,
:architecture
,
:ip_address
,
:contacted_at
,
:executor_type
chronic_duration_attr
:maximum_timeout_human_readable
,
:maximum_timeout
,
chronic_duration_attr
:maximum_timeout_human_readable
,
:maximum_timeout
,
error_message:
'Maximum job timeout has a value which could not be accepted'
error_message:
'Maximum job timeout has a value which could not be accepted'
...
@@ -398,8 +413,9 @@ module Ci
...
@@ -398,8 +413,9 @@ module Ci
# database after heartbeat write happens.
# database after heartbeat write happens.
#
#
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
without_sticky_writes
do
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
without_sticky_writes
do
values
=
values
&
.
slice
(
:version
,
:revision
,
:platform
,
:architecture
,
:ip_address
,
:config
)
||
{}
values
=
values
&
.
slice
(
:version
,
:revision
,
:platform
,
:architecture
,
:ip_address
,
:config
,
:executor
)
||
{}
values
[
:contacted_at
]
=
Time
.
current
values
[
:contacted_at
]
=
Time
.
current
values
[
:executor_type
]
=
EXECUTOR_NAME_TO_TYPES
.
fetch
(
values
.
delete
(
:executor
),
:unknown
)
cache_attributes
(
values
)
cache_attributes
(
values
)
...
@@ -424,6 +440,20 @@ module Ci
...
@@ -424,6 +440,20 @@ module Ci
private
private
EXECUTOR_NAME_TO_TYPES
=
{
'custom'
=>
:custom
,
'shell'
=>
:shell
,
'docker'
=>
:docker
,
'docker-windows'
=>
:docker_windows
,
'docker-ssh'
=>
:docker_ssh
,
'ssh'
=>
:ssh
,
'parallels'
=>
:parallels
,
'virtualbox'
=>
:virtualbox
,
'docker+machine'
=>
:docker_machine
,
'docker-ssh+machine'
=>
:docker_ssh_machine
,
'kubernetes'
=>
:kubernetes
}.
freeze
def
cleanup_runner_queue
def
cleanup_runner_queue
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
del
(
runner_queue_key
)
redis
.
del
(
runner_queue_key
)
...
...
db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb
0 → 100644
View file @
251420dc
# frozen_string_literal: true
class
AddExecutorTypeColumnToCiRunners
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
add_column
:ci_runners
,
:executor_type
,
:smallint
,
null:
true
end
end
db/schema_migrations/20211208111425
0 → 100644
View file @
251420dc
1e3f29ed1a820588da9fe135fbdd0feaa960038b99397dbd7921d4804dce1e1f
\ No newline at end of file
db/structure.sql
View file @
251420dc
...
@@ -12175,7 +12175,8 @@ CREATE TABLE ci_runners (
...
@@ -12175,7 +12175,8 @@ CREATE TABLE ci_runners (
token_encrypted character varying,
token_encrypted character varying,
public_projects_minutes_cost_factor double precision DEFAULT 0.0 NOT NULL,
public_projects_minutes_cost_factor double precision DEFAULT 0.0 NOT NULL,
private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
config jsonb DEFAULT '{}'::jsonb NOT NULL
config jsonb DEFAULT '{}'::jsonb NOT NULL,
executor_type smallint
);
);
CREATE SEQUENCE ci_runners_id_seq
CREATE SEQUENCE ci_runners_id_seq
lib/api/ci/helpers/runner.rb
View file @
251420dc
...
@@ -29,7 +29,7 @@ module API
...
@@ -29,7 +29,7 @@ module API
def
get_runner_details_from_request
def
get_runner_details_from_request
return
get_runner_ip
unless
params
[
'info'
].
present?
return
get_runner_ip
unless
params
[
'info'
].
present?
attributes_for_keys
(
%w(name version revision platform architecture)
,
params
[
'info'
])
attributes_for_keys
(
%w(name version revision platform architecture
executor
)
,
params
[
'info'
])
.
merge
(
get_runner_config_from_request
)
.
merge
(
get_runner_config_from_request
)
.
merge
(
get_runner_ip
)
.
merge
(
get_runner_ip
)
end
end
...
...
spec/lib/api/ci/helpers/runner_helpers_spec.rb
View file @
251420dc
...
@@ -38,6 +38,7 @@ RSpec.describe API::Ci::Helpers::Runner do
...
@@ -38,6 +38,7 @@ RSpec.describe API::Ci::Helpers::Runner do
let
(
:revision
)
{
'10.0'
}
let
(
:revision
)
{
'10.0'
}
let
(
:platform
)
{
'test'
}
let
(
:platform
)
{
'test'
}
let
(
:architecture
)
{
'arm'
}
let
(
:architecture
)
{
'arm'
}
let
(
:executor
)
{
'shell'
}
let
(
:config
)
{
{
'gpus'
=>
'all'
}
}
let
(
:config
)
{
{
'gpus'
=>
'all'
}
}
let
(
:runner_params
)
do
let
(
:runner_params
)
do
{
{
...
@@ -48,6 +49,7 @@ RSpec.describe API::Ci::Helpers::Runner do
...
@@ -48,6 +49,7 @@ RSpec.describe API::Ci::Helpers::Runner do
'revision'
=>
revision
,
'revision'
=>
revision
,
'platform'
=>
platform
,
'platform'
=>
platform
,
'architecture'
=>
architecture
,
'architecture'
=>
architecture
,
'executor'
=>
executor
,
'config'
=>
config
,
'config'
=>
config
,
'ignored'
=>
1
'ignored'
=>
1
}
}
...
@@ -57,12 +59,13 @@ RSpec.describe API::Ci::Helpers::Runner do
...
@@ -57,12 +59,13 @@ RSpec.describe API::Ci::Helpers::Runner do
subject
(
:details
)
{
runner_helper
.
get_runner_details_from_request
}
subject
(
:details
)
{
runner_helper
.
get_runner_details_from_request
}
it
'extracts the runner details'
,
:aggregate_failures
do
it
'extracts the runner details'
,
:aggregate_failures
do
expect
(
details
.
keys
).
to
match_array
(
%w(name version revision platform architecture config ip_address)
)
expect
(
details
.
keys
).
to
match_array
(
%w(name version revision platform architecture
executor
config ip_address)
)
expect
(
details
[
'name'
]).
to
eq
(
name
)
expect
(
details
[
'name'
]).
to
eq
(
name
)
expect
(
details
[
'version'
]).
to
eq
(
version
)
expect
(
details
[
'version'
]).
to
eq
(
version
)
expect
(
details
[
'revision'
]).
to
eq
(
revision
)
expect
(
details
[
'revision'
]).
to
eq
(
revision
)
expect
(
details
[
'platform'
]).
to
eq
(
platform
)
expect
(
details
[
'platform'
]).
to
eq
(
platform
)
expect
(
details
[
'architecture'
]).
to
eq
(
architecture
)
expect
(
details
[
'architecture'
]).
to
eq
(
architecture
)
expect
(
details
[
'executor'
]).
to
eq
(
executor
)
expect
(
details
[
'config'
]).
to
eq
(
config
)
expect
(
details
[
'config'
]).
to
eq
(
config
)
expect
(
details
[
'ip_address'
]).
to
eq
(
ip_address
)
expect
(
details
[
'ip_address'
]).
to
eq
(
ip_address
)
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
251420dc
...
@@ -903,8 +903,9 @@ RSpec.describe Ci::Runner do
...
@@ -903,8 +903,9 @@ RSpec.describe Ci::Runner do
describe
'#heartbeat'
do
describe
'#heartbeat'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:project
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:project
)
}
let
(
:executor
)
{
'shell'
}
subject
{
runner
.
heartbeat
(
architecture:
'18-bit'
,
config:
{
gpus:
"all"
})
}
subject
{
runner
.
heartbeat
(
architecture:
'18-bit'
,
config:
{
gpus:
"all"
}
,
executor:
executor
)
}
context
'when database was updated recently'
do
context
'when database was updated recently'
do
before
do
before
do
...
@@ -940,6 +941,26 @@ RSpec.describe Ci::Runner do
...
@@ -940,6 +941,26 @@ RSpec.describe Ci::Runner do
expect_redis_update
expect_redis_update
does_db_update
does_db_update
end
end
%w(custom shell docker docker-windows docker-ssh ssh parallels virtualbox docker+machine docker-ssh+machine kubernetes some-unknown-type)
.
each
do
|
executor
|
context
"with
#{
executor
}
executor"
do
let
(
:executor
)
{
executor
}
it
'updates with expected executor type'
do
expect_redis_update
subject
expect
(
runner
.
reload
.
read_attribute
(
:executor_type
)).
to
eq
(
expected_executor_type
)
end
def
expected_executor_type
return
'unknown'
if
executor
==
'some-unknown-type'
executor
.
gsub
(
/[+-]/
,
'_'
)
end
end
end
end
end
def
expect_redis_update
def
expect_redis_update
...
@@ -953,6 +974,7 @@ RSpec.describe Ci::Runner do
...
@@ -953,6 +974,7 @@ RSpec.describe Ci::Runner do
expect
{
subject
}.
to
change
{
runner
.
reload
.
read_attribute
(
:contacted_at
)
}
expect
{
subject
}.
to
change
{
runner
.
reload
.
read_attribute
(
:contacted_at
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:architecture
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:architecture
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:config
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:config
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:executor_type
)
}
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