Commit 09d16a36 authored by Stan Hu's avatar Stan Hu

Merge branch '3256-improve-replication-status' into 'master'

Geo: Improve status report

See merge request gitlab-org/gitlab-ee!4164
parents 05d497e1 b6208bc1
---
title: 'Geo - Improve node status report by adding one more indicator of health: last
time when primary pulled the status of the secondary'
merge_request:
author:
type: added
...@@ -58,7 +58,7 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -58,7 +58,7 @@ class GeoNodeStatus < ActiveRecord::Base
def self.allowed_params def self.allowed_params
excluded_params = %w(id created_at updated_at).freeze excluded_params = %w(id created_at updated_at).freeze
extra_params = %w(success health health_status last_event_timestamp cursor_last_event_timestamp version revision storage_shards).freeze extra_params = %w(success health health_status last_event_timestamp cursor_last_event_timestamp version revision storage_shards updated_at).freeze
self.column_names - excluded_params + extra_params self.column_names - excluded_params + extra_params
end end
......
...@@ -1227,6 +1227,8 @@ module API ...@@ -1227,6 +1227,8 @@ module API
expose :namespaces, using: NamespaceBasic expose :namespaces, using: NamespaceBasic
expose :updated_at
# We load GeoNodeStatus data in two ways: # We load GeoNodeStatus data in two ways:
# #
# 1. Directly by asking a Geo node via an API call # 1. Directly by asking a Geo node via an API call
......
...@@ -211,7 +211,7 @@ namespace :geo do ...@@ -211,7 +211,7 @@ namespace :geo do
task status: :environment do task status: :environment do
abort GEO_LICENSE_ERROR_TEXT unless Gitlab::Geo.license_allows? abort GEO_LICENSE_ERROR_TEXT unless Gitlab::Geo.license_allows?
COLUMN_WIDTH = 35 COLUMN_WIDTH = 40
current_node_status = GeoNodeStatus.current_node_status current_node_status = GeoNodeStatus.current_node_status
geo_node = current_node_status.geo_node geo_node = current_node_status.geo_node
...@@ -265,5 +265,15 @@ namespace :geo do ...@@ -265,5 +265,15 @@ namespace :geo do
print cursor_last_event_id print cursor_last_event_id
puts "(#{time_ago_in_words(Geo::EventLog.find_by(id: cursor_last_event_id)&.created_at)} ago)" puts "(#{time_ago_in_words(Geo::EventLog.find_by(id: cursor_last_event_id)&.created_at)} ago)"
end end
print 'Last status was pulled by primary node: '.rjust(COLUMN_WIDTH)
if current_node_status.updated_at
puts "#{time_ago_in_words(current_node_status.updated_at)} ago"
else
# Only primary node can create a status record in the database so if it does not exist
# we get unsaved record where updated_at is nil
puts "Never"
end
end end
end end
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
"namespaces", "namespaces",
"version", "version",
"revision", "revision",
"_links" "_links",
"updated_at"
], ],
"properties" : { "properties" : {
"geo_node_id": { "type": "integer" }, "geo_node_id": { "type": "integer" },
...@@ -84,7 +85,8 @@ ...@@ -84,7 +85,8 @@
"node": { "type": "string" } "node": { "type": "string" }
}, },
"additionalProperties": false "additionalProperties": false
} },
"updated_at": { "type": ["string", "null"] }
}, },
"additionalProperties": false "additionalProperties": false
} }
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