Commit 256b12da authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Kushal Pandya

Expose GitLab version in Geo status API

parent 3ed8b2ee
......@@ -27,7 +27,6 @@ class GeoNodeStatus < ActiveRecord::Base
def self.current_node_status
current_node = Gitlab::Geo.current_node
return unless current_node
status = current_node.find_or_build_status
......@@ -68,6 +67,7 @@ class GeoNodeStatus < ActiveRecord::Base
self.lfs_objects_count = geo_node.lfs_objects.count
self.attachments_count = geo_node.uploads.count
self.last_successful_status_check_at = Time.now
self.version = Gitlab::VERSION
if Gitlab::Geo.secondary?
self.db_replication_lag_seconds = Gitlab::Geo::HealthCheck.db_replication_lag_seconds
......
......@@ -39,6 +39,8 @@ class GeoNodeStatusEntity < Grape::Entity
expose :last_successful_status_check_timestamp
expose :version
expose :namespaces, using: NamespaceEntity
def namespaces
......
......@@ -2,6 +2,7 @@ FactoryGirl.define do
factory :geo_node_status do
sequence(:id)
geo_node
version { Gitlab::VERSION }
trait :healthy do
health nil
......
......@@ -19,7 +19,8 @@
"last_event_timestamp",
"cursor_last_event_id",
"cursor_last_event_timestamp",
"namespaces"
"namespaces",
"version"
],
"properties" : {
"geo_node_id": { "type": "integer" },
......@@ -44,7 +45,8 @@
"cursor_last_event_id": { "type": ["integer", "null"] },
"cursor_last_event_timestamp": { "type": ["integer", "null"] },
"last_successful_status_check_timestamp": { "type": ["integer", "null"] },
"namespaces": { "type": "array" }
"namespaces": { "type": "array" },
"version": { "type": ["string"] }
},
"additionalProperties": false
}
......@@ -62,7 +62,9 @@ describe API::GeoNodes, :geo, api: true do
describe 'GET /geo_nodes/:id/status' do
it 'retrieves the Geo nodes status if admin is logged in' do
stub_current_geo_node(primary)
expect(GeoNodeStatus).not_to receive(:current_node_status)
get api("/geo_nodes/#{secondary.id}/status", admin)
expect(response).to have_gitlab_http_status(200)
......@@ -71,6 +73,7 @@ describe API::GeoNodes, :geo, api: true do
it 'fetches the current node status' do
stub_current_geo_node(secondary)
expect(GeoNode).to receive(:find).and_return(secondary)
expect(GeoNodeStatus).to receive(:current_node_status).and_call_original
......
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