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
af9e0b04
Commit
af9e0b04
authored
Feb 16, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an option to enable/disable a secondary geo node
[ci skip]
parent
3aa3cef4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
4 deletions
+119
-4
app/assets/stylesheets/pages/geo_nodes.scss
app/assets/stylesheets/pages/geo_nodes.scss
+7
-0
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+14
-1
app/helpers/ee/geo_helper.rb
app/helpers/ee/geo_helper.rb
+31
-0
app/models/geo_node.rb
app/models/geo_node.rb
+8
-0
app/views/admin/geo_nodes/_form.html.haml
app/views/admin/geo_nodes/_form.html.haml
+0
-1
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+4
-2
config/routes/admin.rb
config/routes/admin.rb
+1
-0
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+54
-0
No files found.
app/assets/stylesheets/pages/geo_nodes.scss
0 → 100644
View file @
af9e0b04
.geo-node-icon-enabled
{
color
:
$gl-success
;
}
.geo-node-icon-disabled
{
color
:
$gl-danger
;
}
app/controllers/admin/geo_nodes_controller.rb
View file @
af9e0b04
class
Admin::GeoNodesController
<
Admin
::
ApplicationController
before_action
:check_license
,
except:
[
:index
,
:destroy
]
before_action
:load_node
,
only:
[
:destroy
,
:repair
]
before_action
:load_node
,
only:
[
:destroy
,
:repair
,
:toggle
]
def
index
@nodes
=
GeoNode
.
all
...
...
@@ -40,6 +40,19 @@ class Admin::GeoNodesController < Admin::ApplicationController
redirect_to
admin_geo_nodes_path
end
def
toggle
if
@node
.
primary?
flash
[
:alert
]
=
"Primary node can't be disabled."
else
@node
.
toggle!
new_status
=
@node
.
enabled?
?
'enabled'
:
'disabled'
flash
[
:notice
]
=
"Node
#{
@node
.
url
}
was successfully
#{
new_status
}
."
end
redirect_to
admin_geo_nodes_path
end
private
def
geo_node_params
...
...
app/helpers/ee/geo_helper.rb
0 → 100644
View file @
af9e0b04
module
EE
module
GeoHelper
def
node_status_icon
(
node
)
if
node
.
primary?
icon
'star fw'
else
status
=
node
.
enabled?
?
'enabled'
:
'disabled'
icon
'globe fw'
,
class:
"geo-node-icon-
#{
status
}
has-tooltip"
,
title:
status
.
capitalize
end
end
def
toggle_node_button
(
node
)
btn_class
,
title
,
data
=
if
node
.
enabled?
[
'warning'
,
'Disable node'
,
{
confirm:
'Disabling a node stops the repositories backfilling process. Are you sure?'
}]
else
[
'success'
,
'Enable node'
]
end
link_to
icon
(
'power-off fw'
,
text:
title
),
toggle_admin_geo_node_path
(
node
),
method: :post
,
class:
"btn btn-sm btn-
#{
btn_class
}
prepend-left-10 has-tooltip"
,
title:
title
,
data:
data
end
end
end
app/models/geo_node.rb
View file @
af9e0b04
...
...
@@ -31,6 +31,14 @@ class GeoNode < ActiveRecord::Base
mode: :per_attribute_iv
,
encode:
true
def
secondary?
!
primary
end
def
toggle!
update_attribute
(
:enabled
,
!
enabled
)
end
def
uri
if
relative_url_root
relative_url
=
relative_url_root
.
starts_with?
(
'/'
)
?
relative_url_root
:
"/
#{
relative_url_root
}
"
...
...
app/views/admin/geo_nodes/_form.html.haml
View file @
af9e0b04
...
...
@@ -21,7 +21,6 @@
%p
.help-block
Paste a machine public key here for the GitLab user this node runs on. Read more about how to generate it
=
link_to
"here"
,
help_page_path
(
"ssh/README"
)
.form-actions
=
f
.
submit
'Add Node'
,
class:
'btn btn-create'
%hr
app/views/admin/geo_nodes/index.html.haml
View file @
af9e0b04
...
...
@@ -8,7 +8,7 @@
%hr
=
render
:partial
=>
'form'
,
locals:
{
geo_node:
@node
}
if
Gitlab
::
Geo
.
license_allows?
=
render
partial:
'form'
,
locals:
{
geo_node:
@node
}
if
Gitlab
::
Geo
.
license_allows?
-
if
@nodes
.
any?
.panel.panel-default
...
...
@@ -19,7 +19,7 @@
%li
.list-item-name
%span
=
node
.
primary
?
icon
(
'star fw'
)
:
icon
(
'globe fw'
)
=
node
_status_icon
(
node
)
%strong
=
node
.
url
%p
%span
.help-block
=
node
.
primary
?
'Primary node'
:
'Secondary node'
...
...
@@ -30,6 +30,8 @@
=
link_to
repair_admin_geo_node_path
(
node
),
method: :post
,
title:
'OAuth application is missing'
,
class:
'btn btn-default btn-sm prepend-left-10'
do
=
icon
(
'exclamation-triangle fw'
)
Repair authentication
-
if
node
.
secondary?
=
toggle_node_button
(
node
)
=
link_to
admin_geo_node_path
(
node
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-remove btn-sm prepend-left-10'
do
=
icon
'trash'
Remove
config/routes/admin.rb
View file @
af9e0b04
...
...
@@ -113,6 +113,7 @@ namespace :admin do
resources
:geo_nodes
,
only:
[
:index
,
:create
,
:destroy
]
do
member
do
post
:repair
post
:toggle
end
end
## EE-specific
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
af9e0b04
...
...
@@ -115,4 +115,58 @@ describe Admin::GeoNodesController do
it_behaves_like
'unlicensed geo action'
end
describe
'#toggle'
do
subject
{
post
:toggle
,
id:
geo_node
}
context
'without add-on license'
do
let
(
:geo_node
)
{
create
(
:geo_node
)
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
false
)
subject
end
it_behaves_like
'unlicensed geo action'
end
context
'with add-on license'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
true
)
subject
end
context
'with a primary node'
do
let
(
:geo_node
)
{
create
(
:geo_node
,
:primary
,
enabled:
true
)
}
it
'does not disable the node'
do
expect
(
geo_node
.
reload
).
to
be_enabled
end
it
'displays a flash message'
do
expect
(
controller
).
to
set_flash
.
now
[
:alert
].
to
(
"Primary node can't be disabled."
)
end
it
'redirects to the geo nodes page'
do
expect
(
response
).
to
redirect_to
(
admin_geo_nodes_path
)
end
end
context
'with a secondary node'
do
let
(
:geo_node
)
{
create
(
:geo_node
,
host:
'example.com'
,
port:
80
,
enabled:
true
)
}
it
'disables the node'
do
expect
(
geo_node
.
reload
).
not_to
be_enabled
end
it
'displays a flash message'
do
expect
(
controller
).
to
set_flash
.
now
[
:notice
].
to
(
'Node http://example.com/ was successfully disabled.'
)
end
it
'redirects to the geo nodes page'
do
expect
(
response
).
to
redirect_to
(
admin_geo_nodes_path
)
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