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
fa3d3673
Commit
fa3d3673
authored
Jun 02, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Persist Clone URL prefix in geo_nodes table to be used by the secondary
parent
6a25c2cd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
6 deletions
+48
-6
app/models/geo_node.rb
app/models/geo_node.rb
+17
-0
config/initializers/geo.rb
config/initializers/geo.rb
+8
-0
db/migrate/20170602003304_add_clone_url_prefix_to_geo_node.rb
...igrate/20170602003304_add_clone_url_prefix_to_geo_node.rb
+10
-0
db/schema.rb
db/schema.rb
+2
-1
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+11
-5
No files found.
app/models/geo_node.rb
View file @
fa3d3673
...
@@ -95,6 +95,18 @@ class GeoNode < ActiveRecord::Base
...
@@ -95,6 +95,18 @@ class GeoNode < ActiveRecord::Base
self
.
primary?
?
false
:
!
oauth_application
.
present?
self
.
primary?
?
false
:
!
oauth_application
.
present?
end
end
def
update_clone_url!
update_clone_url
# Update with update_column to prevent calling callbacks as this method will
# be called in an initializer and we don't want other callbacks
# to mess with uninitialized dependencies.
if
clone_url_prefix_changed?
Rails
.
logger
.
info
"Geo: modified clone_url_prefix to
#{
clone_url_prefix
}
"
update_column
(
:clone_url_prefix
,
clone_url_prefix
)
end
end
private
private
def
geo_api_url
(
suffix
)
def
geo_api_url
(
suffix
)
...
@@ -134,6 +146,7 @@ class GeoNode < ActiveRecord::Base
...
@@ -134,6 +146,7 @@ class GeoNode < ActiveRecord::Base
if
self
.
primary?
if
self
.
primary?
self
.
oauth_application
=
nil
self
.
oauth_application
=
nil
update_clone_url
else
else
update_oauth_application!
update_oauth_application!
update_system_hook!
update_system_hook!
...
@@ -149,6 +162,10 @@ class GeoNode < ActiveRecord::Base
...
@@ -149,6 +162,10 @@ class GeoNode < ActiveRecord::Base
end
end
end
end
def
update_clone_url
self
.
clone_url_prefix
=
Gitlab
.
config
.
gitlab_shell
.
ssh_path_prefix
end
def
update_oauth_application!
def
update_oauth_application!
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
...
...
config/initializers/geo.rb
View file @
fa3d3673
...
@@ -3,3 +3,11 @@ if File.exist?(Rails.root.join('config/database_geo.yml'))
...
@@ -3,3 +3,11 @@ if File.exist?(Rails.root.join('config/database_geo.yml'))
config
.
geo_database
=
config_for
(
:database_geo
)
config
.
geo_database
=
config_for
(
:database_geo
)
end
end
end
end
begin
if
Gitlab
::
Geo
.
primary?
Gitlab
::
Geo
.
current_node
.
update_clone_url!
end
rescue
warn
'WARNING: Unable to check/update clone_url_prefix for Geo'
end
db/migrate/20170602003304_add_clone_url_prefix_to_geo_node.rb
0 → 100644
View file @
fa3d3673
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddCloneUrlPrefixToGeoNode
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
add_column
:geo_nodes
,
:clone_url_prefix
,
:string
end
end
db/schema.rb
View file @
fa3d3673
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20170
523091700
)
do
ActiveRecord
::
Schema
.
define
(
version:
20170
602003304
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -511,6 +511,7 @@ ActiveRecord::Schema.define(version: 20170523091700) do
...
@@ -511,6 +511,7 @@ ActiveRecord::Schema.define(version: 20170523091700) do
t
.
string
"access_key"
t
.
string
"access_key"
t
.
string
"encrypted_secret_access_key"
t
.
string
"encrypted_secret_access_key"
t
.
string
"encrypted_secret_access_key_iv"
t
.
string
"encrypted_secret_access_key_iv"
t
.
string
"clone_url_prefix"
end
end
add_index
"geo_nodes"
,
[
"access_key"
],
name:
"index_geo_nodes_on_access_key"
,
using: :btree
add_index
"geo_nodes"
,
[
"access_key"
],
name:
"index_geo_nodes_on_access_key"
,
using: :btree
...
...
spec/models/geo_node_spec.rb
View file @
fa3d3673
...
@@ -54,7 +54,7 @@ describe GeoNode, type: :model do
...
@@ -54,7 +54,7 @@ describe GeoNode, type: :model do
end
end
end
end
context
'dependent models for GeoNode'
do
context
'dependent models
and attributes
for GeoNode'
do
let
(
:geo_node_key_attributes
)
{
FactoryGirl
.
build
(
:geo_node_key
).
attributes
}
let
(
:geo_node_key_attributes
)
{
FactoryGirl
.
build
(
:geo_node_key
).
attributes
}
context
'on initialize'
do
context
'on initialize'
do
...
@@ -77,10 +77,6 @@ describe GeoNode, type: :model do
...
@@ -77,10 +77,6 @@ describe GeoNode, type: :model do
expect
(
node
.
oauth_application
).
to
be_persisted
expect
(
node
.
oauth_application
).
to
be_persisted
end
end
it
'has no oauth_application if it is a primary node'
do
expect
(
primary_node
.
oauth_application
).
not_to
be_present
end
it
'has a system_hook if it is a secondary node'
do
it
'has a system_hook if it is a secondary node'
do
expect
(
node
.
system_hook
).
to
be_present
expect
(
node
.
system_hook
).
to
be_present
end
end
...
@@ -93,6 +89,16 @@ describe GeoNode, type: :model do
...
@@ -93,6 +89,16 @@ describe GeoNode, type: :model do
expect
(
node
.
system_hook
.
tag_push_events
).
to
be_falsey
expect
(
node
.
system_hook
.
tag_push_events
).
to
be_falsey
expect
(
node
.
system_hook
.
repository_update_events
).
to
be_truthy
expect
(
node
.
system_hook
.
repository_update_events
).
to
be_truthy
end
end
context
'when is a primary node'
do
it
'has no oauth_application'
do
expect
(
primary_node
.
oauth_application
).
not_to
be_present
end
it
'persists current clone_url_prefix'
do
expect
(
primary_node
.
clone_url_prefix
).
to
be_present
end
end
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