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
baa48794
Commit
baa48794
authored
Mar 02, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed minor mistakes and improved code based on review
parent
38bc8053
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
18 deletions
+31
-18
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+2
-6
app/models/geo_node.rb
app/models/geo_node.rb
+16
-2
app/models/geo_node_key.rb
app/models/geo_node_key.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+5
-3
app/services/geo/notify_nodes_service.rb
app/services/geo/notify_nodes_service.rb
+2
-2
lib/gitlab/geo/update_queue.rb
lib/gitlab/geo/update_queue.rb
+4
-3
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+1
-1
No files found.
app/controllers/admin/geo_nodes_controller.rb
View file @
baa48794
...
...
@@ -2,14 +2,10 @@ class Admin::GeoNodesController < Admin::ApplicationController
def
index
@nodes
=
GeoNode
.
all
@node
=
GeoNode
.
new
@node
.
build_geo_node_key
end
def
create
@node
=
GeoNode
.
new
@node
.
build_geo_node_key
@node
.
attributes
=
geo_node_params
@node
.
geo_node_key
.
title
=
"Geo node:
#{
@node
.
url
}
"
@node
=
GeoNode
.
new
(
geo_node_params
)
if
@node
.
save
redirect_to
admin_geo_nodes_path
,
notice:
'Node was successfully created.'
...
...
@@ -23,7 +19,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
@node
=
GeoNode
.
find
(
params
[
:id
])
@node
.
destroy
redirect_to
admin_geo_nodes_path
redirect_to
admin_geo_nodes_path
,
notice:
'Node was successfully removed.'
end
def
geo_node_params
...
...
app/models/geo_node.rb
View file @
baa48794
...
...
@@ -26,9 +26,11 @@ class GeoNode < ActiveRecord::Base
validates
:schema
,
inclusion:
%w(http https)
validates
:relative_url_root
,
length:
{
minimum:
0
,
allow_nil:
false
}
after_initialize
:check_geo_node_key
after_save
:refresh_bulk_notify_worker_status
after_destroy
:refresh_bulk_notify_worker_status
after_destroy
:destroy_orphaned_geo_node_key
before_validation
:change_geo_node_key_title
def
uri
if
relative_url_root
...
...
@@ -51,7 +53,7 @@ class GeoNode < ActiveRecord::Base
end
def
notify_url
URI
::
join
(
uri
,
"
#{
uri
.
path
}
/"
,
'api/v3/geo/refresh_projects'
).
to_s
URI
.
join
(
uri
,
"
#{
uri
.
path
}
/"
,
"api/
#{
API
::
API
.
version
}
/geo/refresh_projects"
).
to_s
end
private
...
...
@@ -63,6 +65,18 @@ class GeoNode < ActiveRecord::Base
end
def
refresh_bulk_notify_worker_status
Gitlab
::
Geo
.
primary?
?
Gitlab
::
Geo
.
bulk_notify_job
.
try
(
:enable!
)
:
Gitlab
::
Geo
.
bulk_notify_job
.
try
(
:disable!
)
if
Gitlab
::
Geo
.
primary?
Gitlab
::
Geo
.
bulk_notify_job
.
enable!
else
Gitlab
::
Geo
.
bulk_notify_job
.
disable!
end
end
def
check_geo_node_key
self
.
build_geo_node_key
if
geo_node_key
.
nil?
end
def
geo_node_key_title
self
.
geo_node_key
.
title
=
"Geo node:
#{
self
.
url
}
"
end
end
app/models/geo_node_key.rb
View file @
baa48794
...
...
@@ -14,7 +14,7 @@
#
class
GeoNodeKey
<
Key
has_
many
:geo_nodes
has_
one
:geo_nodes
def
orphaned?
self
.
geo_nodes
.
length
==
0
...
...
app/models/repository.rb
View file @
baa48794
...
...
@@ -183,10 +183,12 @@ class Repository
end
def
set_remote_as_mirror
(
name
)
remote_config
=
raw_repository
.
rugged
.
config
# This is used by Gitlab Geo to define repository as equivalent as "git clone --mirror"
r
aw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.fetch"
]
=
'refs/*:refs/*'
r
aw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.mirror"
]
=
true
r
aw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.prune"
]
=
true
r
emote_config
[
"remote.
#{
name
}
.fetch"
]
=
'refs/*:refs/*'
r
emote_config
[
"remote.
#{
name
}
.mirror"
]
=
true
r
emote_config
[
"remote.
#{
name
}
.prune"
]
=
true
end
def
fetch_remote
(
remote
)
...
...
app/services/geo/notify_nodes_service.rb
View file @
baa48794
...
...
@@ -12,7 +12,7 @@ module Geo
::
Gitlab
::
Geo
.
secondary_nodes
.
each
do
|
node
|
success
,
message
=
notify_updated_projects
(
node
,
projects
)
unless
success
Rails
.
logger
.
error
(
"Git
lab F
ailed to notify
#{
node
.
url
}
:
#{
message
}
"
)
Rails
.
logger
.
error
(
"Git
Lab f
ailed to notify
#{
node
.
url
}
:
#{
message
}
"
)
@queue
.
store_batched_data
(
projects
)
end
end
...
...
@@ -28,7 +28,7 @@ module Geo
'PRIVATE-TOKEN'
=>
private_token
})
return
[(
response
.
code
>=
200
&&
response
.
code
<
300
),
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
response
.
to_s
)]
[(
response
.
code
>=
200
&&
response
.
code
<
300
),
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
response
.
to_s
)]
rescue
HTTParty
::
Error
,
Errno
::
ECONNREFUSED
=>
e
return
[
false
,
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
e
.
message
)]
end
...
...
lib/gitlab/geo/update_queue.rb
View file @
baa48794
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Geo
class
UpdateQueue
BATCH_SIZE
=
250
NAMESPACE
=
:geo
NAMESPACE
=
'geo:gitlab'
QUEUE
=
'updated_projects'
def
initialize
...
...
@@ -10,7 +10,8 @@ module Gitlab
end
def
store
(
data
)
@redis
.
rpush
(
QUEUE
,
data
.
to_json
)
and
expire_queue_size!
@redis
.
rpush
(
QUEUE
,
data
.
to_json
)
expire_queue_size!
end
def
first
...
...
@@ -28,7 +29,7 @@ module Gitlab
bsize
=
batch_size
@redis
.
multi
do
projects
=
@redis
.
lrange
(
QUEUE
,
0
,
bsize
-
1
)
projects
=
@redis
.
lrange
(
QUEUE
,
0
,
bsize
-
1
)
@redis
.
ltrim
(
QUEUE
,
bsize
,
-
1
)
end
...
...
lib/gitlab/git_access.rb
View file @
baa48794
...
...
@@ -337,7 +337,7 @@ module Gitlab
end
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
readonly?
return
build_status_object
(
false
,
"You can't use git-an
ex with Gitlab Geo readonl
y node."
)
return
build_status_object
(
false
,
"You can't use git-an
nex with Gitlab Geo secondar
y node."
)
end
if
user
.
can?
(
:push_code
,
project
)
...
...
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