Skip to content
Snippets Groups Projects
Commit a0a7b9a3 authored by Robert Speicher's avatar Robert Speicher Committed by James Lopez
Browse files

Merge branch 'sh-geo-check-for-tracking-db' into 'master'

Return 404 instead of a 500 error on API status endpoint if Geo tracking DB is not enabled

See merge request !1571
parent 349b042e
No related branches found
No related tags found
No related merge requests found
Pipeline #
---
title: Return 404 instead of a 500 error on API status endpoint if Geo tracking DB is not enabled
merge_request:
author:
......@@ -35,6 +35,7 @@ class Geo < Grape::API
get 'status' do
authenticate_by_gitlab_geo_node_token!
require_node_to_be_secondary!
require_node_to_have_tracking_db!
present GeoNodeStatus.new, with: Entities::GeoNodeStatus
end
......@@ -105,6 +106,10 @@ def require_node_to_be_enabled!
def require_node_to_be_secondary!
forbidden! 'Geo node is not secondary node.' unless Gitlab::Geo.current_node&.secondary?
end
def require_node_to_have_tracking_db!
not_found! 'Geo node does not have its tracking database enabled.' unless Gitlab::Geo.configured?
end
end
end
end
......@@ -180,6 +180,14 @@
expect(response.status).to eq 200
expect(response.headers['Content-Type']).to eq('application/json')
end
it 'responds with a 404 when the tracking database is disabled' do
allow(Gitlab::Geo).to receive(:configured?).and_return(false)
get api('/geo/status'), nil, request.headers
expect(response).to have_http_status(404)
end
end
context 'when requesting primary node with valid auth header' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment