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
39fffdff
Commit
39fffdff
authored
May 11, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Gracefully handle a non-JSON response from the node status
See
https://gitlab.com/gitlab-org/gitlab-ee/issues/5993
parent
85681f7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
ee/app/services/geo/node_status_fetch_service.rb
ee/app/services/geo/node_status_fetch_service.rb
+5
-1
ee/changelogs/unreleased/sh-geo-handle-invalid-json-response.yml
...gelogs/unreleased/sh-geo-handle-invalid-json-response.yml
+5
-0
ee/spec/services/geo/node_status_fetch_service_spec.rb
ee/spec/services/geo/node_status_fetch_service_spec.rb
+12
-0
No files found.
ee/app/services/geo/node_status_fetch_service.rb
View file @
39fffdff
...
...
@@ -11,7 +11,11 @@ module Geo
data
[
:success
]
=
response
.
success?
if
response
.
success?
data
.
merge!
(
response
.
parsed_response
)
if
response
.
parsed_response
.
is_a?
(
Hash
)
data
.
merge!
(
response
.
parsed_response
)
else
data
[
:health
]
=
'A JSON response was not received'
end
else
message
=
"Could not connect to Geo node - HTTP Status Code:
#{
response
.
code
}
#{
response
.
message
}
"
payload
=
response
.
parsed_response
...
...
ee/changelogs/unreleased/sh-geo-handle-invalid-json-response.yml
0 → 100644
View file @
39fffdff
---
title
:
'
Geo:
Gracefully
handle
a
non-JSON
response
from
the
node
status'
merge_request
:
author
:
type
:
fixed
ee/spec/services/geo/node_status_fetch_service_spec.rb
View file @
39fffdff
...
...
@@ -79,6 +79,18 @@ describe Geo::NodeStatusFetchService, :geo do
expect
(
status
.
success
).
to
be
true
end
it
'handles invalid JSON response'
do
request
=
double
(
success?:
true
,
code:
200
,
message:
'Something here'
,
parsed_response:
'Something here'
)
allow
(
Gitlab
::
HTTP
).
to
receive
(
:get
).
and_return
(
request
)
status
=
subject
.
call
(
secondary
)
expect
(
status
.
status_message
).
to
eq
(
"A JSON response was not received"
)
end
it
'omits full response text in status'
do
request
=
double
(
success?:
false
,
code:
401
,
...
...
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