Commit c476b27a authored by Robert Speicher's avatar Robert Speicher

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
parents 871454de 812754d1
---
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 @@ module 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 @@ module API
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 @@ describe API::Geo, api: true do
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment