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
a4d08e6b
Commit
a4d08e6b
authored
Mar 18, 2017
by
Rydkin Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename `auto_canceled_by` and add foreign key
parent
40f67c1d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
19 deletions
+28
-19
pipeline.rb
app/models/ci/pipeline.rb
+2
-0
create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-1
20170312114329_add_auto_canceled_by_id_to_pipeline.rb
...ate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb
+10
-4
schema.rb
db/schema.rb
+10
-9
create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+5
-5
No files found.
app/models/ci/pipeline.rb
View file @
a4d08e6b
...
...
@@ -7,7 +7,9 @@ module Ci
belongs_to
:project
belongs_to
:user
belongs_to
:auto_canceled_by
,
class_name:
'Ci::Pipeline'
has_many
:auto_canceled_pipelines
,
class_name:
'Ci::Pipeline'
,
foreign_key:
'auto_canceled_by_id'
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :commit_id
has_many
:builds
,
foreign_key: :commit_id
has_many
:trigger_requests
,
dependent: :destroy
,
foreign_key: :commit_id
...
...
app/services/ci/create_pipeline_service.rb
View file @
a4d08e6b
...
...
@@ -69,7 +69,7 @@ module Ci
Gitlab
::
OptimisticLocking
.
retry_lock
(
auto_cancelable_pipelines
)
do
|
cancelables
|
cancelables
.
find_each
do
|
cancelable
|
cancelable
.
cancel_running
cancelable
.
update_attributes
(
auto_canceled_by:
pipeline
.
id
)
cancelable
.
update_attributes
(
auto_canceled_by
_id
:
pipeline
.
id
)
end
end
end
...
...
db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb
→
db/migrate/20170312114329_add_auto_canceled_by_
id_
to_pipeline.rb
View file @
a4d08e6b
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddAutoCanceledByToPipeline
<
ActiveRecord
::
Migration
class
AddAutoCanceledBy
Id
ToPipeline
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
...
...
@@ -21,9 +21,15 @@ class AddAutoCanceledByToPipeline < ActiveRecord::Migration
#
# To disable transactions uncomment the following line and remove these
# comments:
#
disable_ddl_transaction!
disable_ddl_transaction!
def
change
add_column
:ci_commits
,
:auto_canceled_by
,
:integer
def
up
add_column
:ci_pipelines
,
:auto_canceled_by_id
,
:integer
add_concurrent_foreign_key
:ci_pipelines
,
:ci_pipelines
,
column: :auto_canceled_by_id
,
on_delete:
'set null'
end
def
down
remove_foreign_key
:ci_pipelines
,
column: :auto_canceled_by_id
remove_column
:ci_pipelines
,
:auto_canceled_by_id
end
end
db/schema.rb
View file @
a4d08e6b
...
...
@@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
boolean
"shared_runners_enabled"
,
default:
true
,
null:
false
t
.
integer
"max_artifacts_size"
,
default:
100
,
null:
false
t
.
string
"runners_registration_token"
t
.
integer
"max_pages_size"
,
default:
100
,
null:
false
t
.
boolean
"require_two_factor_authentication"
,
default:
false
t
.
integer
"two_factor_grace_period"
,
default:
48
t
.
boolean
"metrics_enabled"
,
default:
false
...
...
@@ -99,17 +98,18 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
text
"help_page_text_html"
t
.
text
"shared_runners_text_html"
t
.
text
"after_sign_up_text_html"
t
.
boolean
"sidekiq_throttling_enabled"
,
default:
false
t
.
string
"sidekiq_throttling_queues"
t
.
decimal
"sidekiq_throttling_factor"
t
.
boolean
"housekeeping_enabled"
,
default:
true
,
null:
false
t
.
boolean
"housekeeping_bitmaps_enabled"
,
default:
true
,
null:
false
t
.
integer
"housekeeping_incremental_repack_period"
,
default:
10
,
null:
false
t
.
integer
"housekeeping_full_repack_period"
,
default:
50
,
null:
false
t
.
integer
"housekeeping_gc_period"
,
default:
200
,
null:
false
t
.
boolean
"sidekiq_throttling_enabled"
,
default:
false
t
.
string
"sidekiq_throttling_queues"
t
.
decimal
"sidekiq_throttling_factor"
t
.
boolean
"html_emails_enabled"
,
default:
true
t
.
string
"plantuml_url"
t
.
boolean
"plantuml_enabled"
t
.
integer
"max_pages_size"
,
default:
100
,
null:
false
t
.
integer
"terminal_max_session_time"
,
default:
0
,
null:
false
t
.
string
"default_artifacts_expire_in"
,
default:
"0"
,
null:
false
t
.
integer
"unique_ips_limit_per_user"
...
...
@@ -251,7 +251,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
integer
"duration"
t
.
integer
"user_id"
t
.
integer
"lock_version"
t
.
integer
"auto_canceled_by"
t
.
integer
"auto_canceled_by
_id
"
end
add_index
"ci_pipelines"
,
[
"project_id"
,
"ref"
,
"status"
],
name:
"index_ci_pipelines_on_project_id_and_ref_and_status"
,
using: :btree
...
...
@@ -688,10 +688,10 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
string
"avatar"
t
.
boolean
"share_with_group_lock"
,
default:
false
t
.
integer
"visibility_level"
,
default:
20
,
null:
false
t
.
datetime
"deleted_at"
t
.
boolean
"request_access_enabled"
,
default:
false
,
null:
false
t
.
text
"description_html
"
t
.
datetime
"deleted_at
"
t
.
boolean
"lfs_enabled"
t
.
text
"description_html"
t
.
integer
"parent_id"
end
...
...
@@ -920,8 +920,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
boolean
"lfs_enabled"
t
.
text
"description_html"
t
.
boolean
"only_allow_merge_if_all_discussions_are_resolved"
t
.
boolean
"printing_merge_request_link_enabled"
,
default:
true
,
null:
false
t
.
integer
"auto_cancel_pending_pipelines"
,
default:
0
,
null:
false
t
.
boolean
"printing_merge_request_link_enabled"
,
default:
true
,
null:
false
end
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
...
...
@@ -1241,10 +1241,10 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
boolean
"hide_project_limit"
,
default:
false
t
.
string
"unlock_token"
t
.
datetime
"otp_grace_period_started_at"
t
.
string
"incoming_email_token"
t
.
boolean
"ldap_email"
,
default:
false
,
null:
false
t
.
boolean
"external"
,
default:
false
t
.
string
"organization"
t
.
string
"incoming_email_token"
t
.
boolean
"authorized_projects_populated"
t
.
boolean
"ghost"
t
.
boolean
"notified_of_own_activity"
...
...
@@ -1299,6 +1299,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do
add_foreign_key
"boards"
,
"projects"
add_foreign_key
"chat_teams"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"ci_pipelines"
,
"ci_pipelines"
,
column:
"auto_canceled_by_id"
,
name:
"fk_262d4c2d19"
,
on_delete: :nullify
add_foreign_key
"ci_triggers"
,
"users"
,
column:
"owner_id"
,
name:
"fk_e8e10d1964"
,
on_delete: :cascade
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"label_priorities"
,
"labels"
,
on_delete: :cascade
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
a4d08e6b
...
...
@@ -52,14 +52,14 @@ describe Ci::CreatePipelineService, services: true do
previous_pipeline
=
pipeline_on_previous_commit
expect
(
pipeline
.
reload
)
.
to
have_attributes
(
status:
'pending'
,
auto_canceled_by:
nil
)
.
to
have_attributes
(
status:
'pending'
,
auto_canceled_by
_id
:
nil
)
end
it
'auto cancel pending non-HEAD pipelines'
do
pending_pipeline
=
pipeline_on_previous_commit
pipeline
expect
(
pending_pipeline
.
reload
).
to
have_attributes
(
status:
'canceled'
,
auto_canceled_by:
pipeline
.
id
)
expect
(
pending_pipeline
.
reload
).
to
have_attributes
(
status:
'canceled'
,
auto_canceled_by
_id
:
pipeline
.
id
)
end
it
'does not cancel running outdated pipelines'
do
...
...
@@ -67,7 +67,7 @@ describe Ci::CreatePipelineService, services: true do
running_pipeline
.
run
execute_service
expect
(
running_pipeline
.
reload
).
to
have_attributes
(
status:
'running'
,
auto_canceled_by:
nil
)
expect
(
running_pipeline
.
reload
).
to
have_attributes
(
status:
'running'
,
auto_canceled_by
_id
:
nil
)
end
it
'cancel created outdated pipelines'
do
...
...
@@ -75,7 +75,7 @@ describe Ci::CreatePipelineService, services: true do
created_pipeline
.
update
(
status:
'created'
)
pipeline
expect
(
created_pipeline
.
reload
).
to
have_attributes
(
status:
'canceled'
,
auto_canceled_by:
pipeline
.
id
)
expect
(
created_pipeline
.
reload
).
to
have_attributes
(
status:
'canceled'
,
auto_canceled_by
_id
:
pipeline
.
id
)
end
it
'does not cancel pipelines from the other branches'
do
...
...
@@ -85,7 +85,7 @@ describe Ci::CreatePipelineService, services: true do
)
pipeline
expect
(
pending_pipeline
.
reload
).
to
have_attributes
(
status:
'pending'
,
auto_canceled_by:
nil
)
expect
(
pending_pipeline
.
reload
).
to
have_attributes
(
status:
'pending'
,
auto_canceled_by
_id
:
nil
)
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