BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0d30b00d
Commit
0d30b00d
authored
Apr 30, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start persisting runner_type when creating runners
parent
3dbcc02d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
4 deletions
+40
-4
runner.rb
app/models/ci/runner.rb
+6
-0
20180430101916_add_runner_type_to_ci_runners.rb
db/migrate/20180430101916_add_runner_type_to_ci_runners.rb
+9
-0
20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
...43705_backfill_runner_type_for_ci_runners_post_migrate.rb
+20
-0
schema.rb
db/schema.rb
+2
-1
runner.rb
lib/api/runner.rb
+3
-3
No files found.
app/models/ci/runner.rb
View file @
0d30b00d
...
...
@@ -67,6 +67,12 @@ module Ci
ref_protected:
1
}
enum
runner_type:
{
instance_type:
1
,
group_type:
2
,
project_type:
3
}
cached_attr_reader
:version
,
:revision
,
:platform
,
:architecture
,
:contacted_at
,
:ip_address
chronic_duration_attr
:maximum_timeout_human_readable
,
:maximum_timeout
...
...
db/migrate/20180430101916_add_runner_type_to_ci_runners.rb
0 → 100644
View file @
0d30b00d
class
AddRunnerTypeToCiRunners
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:ci_runners
,
:runner_type
,
:integer
end
end
db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
0 → 100644
View file @
0d30b00d
class
BackfillRunnerTypeForCiRunnersPostMigrate
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
update_column_in_batches
(
:ci_runners
,
:runner_type
,
1
)
do
|
table
,
query
|
query
.
where
(
table
[
:is_shared
].
eq
(
true
)).
where
(
table
[
:runner_type
].
eq
(
nil
))
end
update_column_in_batches
(
:ci_runners
,
:runner_type
,
3
)
do
|
table
,
query
|
query
.
where
(
table
[
:is_shared
].
eq
(
false
)).
where
(
table
[
:runner_type
].
eq
(
nil
))
end
end
def
down
end
end
db/schema.rb
View file @
0d30b00d
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201804
25131009
)
do
ActiveRecord
::
Schema
.
define
(
version:
201804
30143705
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -479,6 +479,7 @@ ActiveRecord::Schema.define(version: 20180425131009) do
t
.
integer
"access_level"
,
default:
0
,
null:
false
t
.
string
"ip_address"
t
.
integer
"maximum_timeout"
t
.
integer
"runner_type"
end
add_index
"ci_runners"
,
[
"contacted_at"
],
name:
"index_ci_runners_on_contacted_at"
,
using: :btree
...
...
lib/api/runner.rb
View file @
0d30b00d
...
...
@@ -23,13 +23,13 @@ module API
runner
=
if
runner_registration_token_valid?
# Create shared runner. Requires admin access
Ci
::
Runner
.
create
(
attributes
.
merge
(
is_shared:
true
))
Ci
::
Runner
.
create
(
attributes
.
merge
(
is_shared:
true
,
runner_type: :instance_type
))
elsif
project
=
Project
.
find_by
(
runners_token:
params
[
:token
])
# Create a specific runner for the project
project
.
runners
.
create
(
attributes
)
project
.
runners
.
create
(
attributes
.
merge
(
runner_type: :project_type
)
)
elsif
group
=
Group
.
find_by
(
runners_token:
params
[
:token
])
# Create a specific runner for the group
group
.
runners
.
create
(
attributes
)
group
.
runners
.
create
(
attributes
.
merge
(
runner_type: :group_type
)
)
end
break
forbidden!
unless
runner
...
...
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