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
belongs_to :geo_node
# Whether we were successful in reaching this node
attr_accessor :success
attr_accessor :health_status
attr_accessor :success, :health_status, :version, :revision
# Be sure to keep this consistent with Prometheus naming conventions
PROMETHEUS_METRICS = {
......@@ -48,7 +47,7 @@ class GeoNodeStatus < ActiveRecord::Base
def self.allowed_params
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
end
......@@ -67,7 +66,6 @@ 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
......
......@@ -40,10 +40,21 @@ class GeoNodeStatusEntity < Grape::Entity
expose :last_successful_status_check_timestamp
expose :version
expose :revision
expose :namespaces, using: NamespaceEntity
private
def namespaces
object.geo_node.namespaces
end
def version
Gitlab::VERSION
end
def revision
Gitlab::REVISION
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 @@
#
# 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
enable_extension "plpgsql"
......@@ -971,7 +971,6 @@ ActiveRecord::Schema.define(version: 20171206225142) do
t.datetime "updated_at", null: false
t.datetime "last_successful_status_check_at"
t.string "status_message"
t.string "version"
end
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:
"cursor_last_event_id": 23,
"cursor_last_event_timestamp": 1509681166,
"last_successful_status_check_timestamp": 1510125024,
"version": "10.3.0"
"version": "10.3.0",
"revision": "33d33a096a"
}
]
```
......@@ -138,7 +139,8 @@ Example response:
"cursor_last_event_id": 23,
"cursor_last_event_timestamp": 1509681166,
"last_successful_status_check_timestamp": 1510125268,
"version": "10.3.0"
"version": "10.3.0",
"revision": "33d33a096a"
}
```
......
......@@ -2,7 +2,6 @@ FactoryGirl.define do
factory :geo_node_status do
sequence(:id)
geo_node
version { Gitlab::VERSION }
trait :healthy do
health nil
......
......@@ -20,7 +20,8 @@
"cursor_last_event_id",
"cursor_last_event_timestamp",
"namespaces",
"version"
"version",
"revision"
],
"properties" : {
"geo_node_id": { "type": "integer" },
......@@ -46,7 +47,8 @@
"cursor_last_event_timestamp": { "type": ["integer", "null"] },
"last_successful_status_check_timestamp": { "type": ["integer", "null"] },
"namespaces": { "type": "array" },
"version": { "type": ["string"] }
"version": { "type": ["string"] },
"revision": { "type": ["string"] }
},
"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