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

Expose GitLab revision in Geo status API

parent bf3df4b1
...@@ -2,8 +2,7 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -2,8 +2,7 @@ class GeoNodeStatus < ActiveRecord::Base
belongs_to :geo_node belongs_to :geo_node
# Whether we were successful in reaching this node # Whether we were successful in reaching this node
attr_accessor :success attr_accessor :success, :health_status, :version, :revision
attr_accessor :health_status
# Be sure to keep this consistent with Prometheus naming conventions # Be sure to keep this consistent with Prometheus naming conventions
PROMETHEUS_METRICS = { PROMETHEUS_METRICS = {
...@@ -48,7 +47,7 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -48,7 +47,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).freeze extra_params = %w(success health health_status last_event_timestamp cursor_last_event_timestamp version revision).freeze
self.column_names - excluded_params + extra_params self.column_names - excluded_params + extra_params
end end
...@@ -67,7 +66,6 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -67,7 +66,6 @@ class GeoNodeStatus < ActiveRecord::Base
self.lfs_objects_count = geo_node.lfs_objects.count self.lfs_objects_count = geo_node.lfs_objects.count
self.attachments_count = geo_node.uploads.count self.attachments_count = geo_node.uploads.count
self.last_successful_status_check_at = Time.now self.last_successful_status_check_at = Time.now
self.version = Gitlab::VERSION
if Gitlab::Geo.secondary? if Gitlab::Geo.secondary?
self.db_replication_lag_seconds = Gitlab::Geo::HealthCheck.db_replication_lag_seconds self.db_replication_lag_seconds = Gitlab::Geo::HealthCheck.db_replication_lag_seconds
......
...@@ -40,10 +40,21 @@ class GeoNodeStatusEntity < Grape::Entity ...@@ -40,10 +40,21 @@ class GeoNodeStatusEntity < Grape::Entity
expose :last_successful_status_check_timestamp expose :last_successful_status_check_timestamp
expose :version expose :version
expose :revision
expose :namespaces, using: NamespaceEntity expose :namespaces, using: NamespaceEntity
private
def namespaces def namespaces
object.geo_node.namespaces object.geo_node.namespaces
end end
def version
Gitlab::VERSION
end
def revision
Gitlab::REVISION
end
end end
class AddVersionToGeoNodeStatuses < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :geo_node_statuses, :version, :string
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171206225142) do ActiveRecord::Schema.define(version: 20171205190711) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -971,7 +971,6 @@ ActiveRecord::Schema.define(version: 20171206225142) do ...@@ -971,7 +971,6 @@ ActiveRecord::Schema.define(version: 20171206225142) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.datetime "last_successful_status_check_at" t.datetime "last_successful_status_check_at"
t.string "status_message" t.string "status_message"
t.string "version"
end end
add_index "geo_node_statuses", ["geo_node_id"], name: "index_geo_node_statuses_on_geo_node_id", unique: true, using: :btree add_index "geo_node_statuses", ["geo_node_id"], name: "index_geo_node_statuses_on_geo_node_id", unique: true, using: :btree
......
...@@ -98,7 +98,8 @@ Example response: ...@@ -98,7 +98,8 @@ Example response:
"cursor_last_event_id": 23, "cursor_last_event_id": 23,
"cursor_last_event_timestamp": 1509681166, "cursor_last_event_timestamp": 1509681166,
"last_successful_status_check_timestamp": 1510125024, "last_successful_status_check_timestamp": 1510125024,
"version": "10.3.0" "version": "10.3.0",
"revision": "33d33a096a"
} }
] ]
``` ```
...@@ -138,7 +139,8 @@ Example response: ...@@ -138,7 +139,8 @@ Example response:
"cursor_last_event_id": 23, "cursor_last_event_id": 23,
"cursor_last_event_timestamp": 1509681166, "cursor_last_event_timestamp": 1509681166,
"last_successful_status_check_timestamp": 1510125268, "last_successful_status_check_timestamp": 1510125268,
"version": "10.3.0" "version": "10.3.0",
"revision": "33d33a096a"
} }
``` ```
......
...@@ -2,7 +2,6 @@ FactoryGirl.define do ...@@ -2,7 +2,6 @@ FactoryGirl.define do
factory :geo_node_status do factory :geo_node_status do
sequence(:id) sequence(:id)
geo_node geo_node
version { Gitlab::VERSION }
trait :healthy do trait :healthy do
health nil health nil
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
"cursor_last_event_id", "cursor_last_event_id",
"cursor_last_event_timestamp", "cursor_last_event_timestamp",
"namespaces", "namespaces",
"version" "version",
"revision"
], ],
"properties" : { "properties" : {
"geo_node_id": { "type": "integer" }, "geo_node_id": { "type": "integer" },
...@@ -46,7 +47,8 @@ ...@@ -46,7 +47,8 @@
"cursor_last_event_timestamp": { "type": ["integer", "null"] }, "cursor_last_event_timestamp": { "type": ["integer", "null"] },
"last_successful_status_check_timestamp": { "type": ["integer", "null"] }, "last_successful_status_check_timestamp": { "type": ["integer", "null"] },
"namespaces": { "type": "array" }, "namespaces": { "type": "array" },
"version": { "type": ["string"] } "version": { "type": ["string"] },
"revision": { "type": ["string"] }
}, },
"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