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
b06f1781
Commit
b06f1781
authored
Jun 11, 2018
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Geo] If node status is not build, return 404 error
parent
885fb839
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+12
-2
ee/lib/api/geo_nodes.rb
ee/lib/api/geo_nodes.rb
+1
-1
ee/spec/models/geo_node_status_spec.rb
ee/spec/models/geo_node_status_spec.rb
+2
-0
ee/spec/requests/api/geo_nodes_spec.rb
ee/spec/requests/api/geo_nodes_spec.rb
+13
-0
No files found.
ee/app/models/geo_node_status.rb
View file @
b06f1781
...
...
@@ -91,8 +91,18 @@ class GeoNodeStatus < ActiveRecord::Base
end
def
self
.
fast_current_node_status
attrs
=
Rails
.
cache
.
read
(
cache_key
)
||
{}
new
(
attrs
)
attrs
=
Rails
.
cache
.
read
(
cache_key
)
if
attrs
new
(
attrs
)
else
spawn_worker
nil
end
end
def
self
.
spawn_worker
::
Geo
::
MetricsUpdateWorker
.
perform_async
end
def
self
.
cache_key
...
...
ee/lib/api/geo_nodes.rb
View file @
b06f1781
...
...
@@ -67,7 +67,7 @@ module API
if
geo_node
.
current?
GeoNodeStatus
.
fast_current_node_status
else
geo_node
.
find_or_build_
status
geo_node
.
status
end
end
end
...
...
ee/spec/models/geo_node_status_spec.rb
View file @
b06f1781
...
...
@@ -20,6 +20,8 @@ describe GeoNodeStatus, :geo do
describe
'#fast_current_node_status'
do
it
'reads the cache and spawns the worker'
do
expect
(
described_class
).
to
receive
(
:spawn_worker
).
once
rails_cache
=
double
expect
(
rails_cache
).
to
receive
(
:read
).
with
(
described_class
.
cache_key
)
expect
(
Rails
).
to
receive
(
:cache
).
and_return
(
rails_cache
)
...
...
ee/spec/requests/api/geo_nodes_spec.rb
View file @
b06f1781
...
...
@@ -92,6 +92,7 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
it
'fetches the current node status'
do
stub_current_geo_node
(
secondary
)
expect
(
GeoNodeStatus
).
to
receive
(
:fast_current_node_status
).
and_return
(
secondary_status
)
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/status"
,
admin
)
...
...
@@ -100,6 +101,16 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
expect
(
response
).
to
match_response_schema
(
'public_api/v4/geo_node_status'
,
dir:
'ee'
)
end
it
'shows 404 response if current node status does not exist yet'
do
stub_current_geo_node
(
secondary
)
expect
(
GeoNode
).
to
receive
(
:find
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/status"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it_behaves_like
'404 response'
do
let
(
:request
)
{
get
api
(
"/geo_nodes/
#{
unexisting_node_id
}
/status"
,
admin
)
}
end
...
...
@@ -123,6 +134,8 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
end
it
'returns 200 for the primary node'
do
expect
(
GeoNodeStatus
).
to
receive
(
:fast_current_node_status
).
and_return
(
secondary_status
)
post
api
(
"/geo_nodes/
#{
primary
.
id
}
/repair"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
...
...
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