Gitaly Server info for admin panel
Implements the client side for gitlab-org/gitaly#819. Which is a server info command. This checks the server version and git binairy version on the server. A small UI was added for administrators, so they can check the status of the Gitaly server. This is done for each storage the monolith knows. Because of this commit, gitlab-org/gitlab-ce!15580 is now closed. That MR removed the Git version too, but didn't replace it with anything.
This commit is contained in:
parent
e74e6fcb5e
commit
94a3dbca33
|
@ -1 +1 @@
|
||||||
0.74.0
|
0.76.0
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -406,7 +406,7 @@ group :ed25519 do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gitaly GRPC client
|
# Gitaly GRPC client
|
||||||
gem 'gitaly-proto', '~> 0.78.0', require: 'gitaly'
|
gem 'gitaly-proto', '~> 0.83.0', require: 'gitaly'
|
||||||
|
|
||||||
gem 'toml-rb', '~> 0.3.15', require: false
|
gem 'toml-rb', '~> 0.3.15', require: false
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ GEM
|
||||||
po_to_json (>= 1.0.0)
|
po_to_json (>= 1.0.0)
|
||||||
rails (>= 3.2.0)
|
rails (>= 3.2.0)
|
||||||
gherkin-ruby (0.3.2)
|
gherkin-ruby (0.3.2)
|
||||||
gitaly-proto (0.78.0)
|
gitaly-proto (0.83.0)
|
||||||
google-protobuf (~> 3.1)
|
google-protobuf (~> 3.1)
|
||||||
grpc (~> 1.0)
|
grpc (~> 1.0)
|
||||||
github-linguist (4.7.6)
|
github-linguist (4.7.6)
|
||||||
|
@ -340,7 +340,7 @@ GEM
|
||||||
mime-types (~> 3.0)
|
mime-types (~> 3.0)
|
||||||
representable (~> 3.0)
|
representable (~> 3.0)
|
||||||
retriable (>= 2.0, < 4.0)
|
retriable (>= 2.0, < 4.0)
|
||||||
google-protobuf (3.4.1.1)
|
google-protobuf (3.5.1.1-universal-darwin)
|
||||||
googleapis-common-protos-types (1.0.1)
|
googleapis-common-protos-types (1.0.1)
|
||||||
google-protobuf (~> 3.0)
|
google-protobuf (~> 3.0)
|
||||||
googleauth (0.5.3)
|
googleauth (0.5.3)
|
||||||
|
@ -369,7 +369,7 @@ GEM
|
||||||
rake
|
rake
|
||||||
grape_logging (1.7.0)
|
grape_logging (1.7.0)
|
||||||
grape
|
grape
|
||||||
grpc (1.8.3)
|
grpc (1.8.3-universal-darwin)
|
||||||
google-protobuf (~> 3.1)
|
google-protobuf (~> 3.1)
|
||||||
googleapis-common-protos-types (~> 1.0.0)
|
googleapis-common-protos-types (~> 1.0.0)
|
||||||
googleauth (>= 0.5.1, < 0.7)
|
googleauth (>= 0.5.1, < 0.7)
|
||||||
|
@ -1056,7 +1056,7 @@ DEPENDENCIES
|
||||||
gettext (~> 3.2.2)
|
gettext (~> 3.2.2)
|
||||||
gettext_i18n_rails (~> 1.8.0)
|
gettext_i18n_rails (~> 1.8.0)
|
||||||
gettext_i18n_rails_js (~> 1.2.0)
|
gettext_i18n_rails_js (~> 1.2.0)
|
||||||
gitaly-proto (~> 0.78.0)
|
gitaly-proto (~> 0.83.0)
|
||||||
github-linguist (~> 4.7.0)
|
github-linguist (~> 4.7.0)
|
||||||
gitlab-flowdock-git-hook (~> 1.0.1)
|
gitlab-flowdock-git-hook (~> 1.0.1)
|
||||||
gitlab-markup (~> 1.6.2)
|
gitlab-markup (~> 1.6.2)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class Admin::GitalyServersController < Admin::ApplicationController
|
||||||
|
def index
|
||||||
|
@gitaly_servers = Gitaly::Server.all
|
||||||
|
end
|
||||||
|
end
|
|
@ -138,19 +138,11 @@
|
||||||
GitLab API
|
GitLab API
|
||||||
%span.pull-right
|
%span.pull-right
|
||||||
= API::API::version
|
= API::API::version
|
||||||
%p
|
|
||||||
Gitaly
|
|
||||||
%span.pull-right
|
|
||||||
= Gitlab::GitalyClient.expected_server_version
|
|
||||||
- if Gitlab.config.pages.enabled
|
- if Gitlab.config.pages.enabled
|
||||||
%p
|
%p
|
||||||
GitLab Pages
|
GitLab Pages
|
||||||
%span.pull-right
|
%span.pull-right
|
||||||
= Gitlab::Pages::VERSION
|
= Gitlab::Pages::VERSION
|
||||||
%p
|
|
||||||
Git
|
|
||||||
%span.pull-right
|
|
||||||
= Gitlab::Git.version
|
|
||||||
%p
|
%p
|
||||||
Ruby
|
Ruby
|
||||||
%span.pull-right
|
%span.pull-right
|
||||||
|
@ -163,6 +155,8 @@
|
||||||
= Gitlab::Database.adapter_name
|
= Gitlab::Database.adapter_name
|
||||||
%span.pull-right
|
%span.pull-right
|
||||||
= Gitlab::Database.version
|
= Gitlab::Database.version
|
||||||
|
%p
|
||||||
|
= link_to "Gitaly Servers", admin_gitaly_servers_path
|
||||||
.row
|
.row
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.info-well
|
.info-well
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
- breadcrumb_title _("Gitaly Servers")
|
||||||
|
|
||||||
|
%h3.page-title= _("Gitaly Servers")
|
||||||
|
%hr
|
||||||
|
.gitaly_servers
|
||||||
|
- if @gitaly_servers.any?
|
||||||
|
.table-holder
|
||||||
|
%table.table.responsive-table
|
||||||
|
%thead.hidden-sm.hidden-xs
|
||||||
|
%tr
|
||||||
|
%th= _("Storage")
|
||||||
|
%th= n_("Gitaly|Address")
|
||||||
|
%th= _("Server version")
|
||||||
|
%th= _("Git version")
|
||||||
|
%th= _("Up to date")
|
||||||
|
- @gitaly_servers.each do |server|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
= server.storage
|
||||||
|
%td
|
||||||
|
= server.address
|
||||||
|
%td
|
||||||
|
= server.server_version
|
||||||
|
%td
|
||||||
|
= server.git_binary_version
|
||||||
|
%td
|
||||||
|
= boolean_to_icon(server.up_to_date?)
|
||||||
|
- else
|
||||||
|
.empty-state
|
||||||
|
.text-center
|
||||||
|
%h4= _("No connection could be made to a Gitaly Server, please check your logs!")
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Add Gitaly Servers admin dashboard
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: added
|
|
@ -24,6 +24,8 @@ namespace :admin do
|
||||||
resource :impersonation, only: :destroy
|
resource :impersonation, only: :destroy
|
||||||
|
|
||||||
resources :abuse_reports, only: [:index, :destroy]
|
resources :abuse_reports, only: [:index, :destroy]
|
||||||
|
resources :gitaly_servers, only: [:index]
|
||||||
|
|
||||||
resources :spam_logs, only: [:index, :destroy] do
|
resources :spam_logs, only: [:index, :destroy] do
|
||||||
member do
|
member do
|
||||||
post :mark_as_ham
|
post :mark_as_ham
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
module Gitaly
|
||||||
|
class Server
|
||||||
|
def self.all
|
||||||
|
Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) }
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_reader :storage
|
||||||
|
|
||||||
|
def initialize(storage)
|
||||||
|
@storage = storage
|
||||||
|
end
|
||||||
|
|
||||||
|
def server_version
|
||||||
|
info.server_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def git_binary_version
|
||||||
|
info.git_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def up_to_date?
|
||||||
|
server_version == Gitlab::GitalyClient.expected_server_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def address
|
||||||
|
Gitlab::GitalyClient.address(@storage)
|
||||||
|
rescue RuntimeError => e
|
||||||
|
"Error getting the address: #{e.message}"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def info
|
||||||
|
@info ||=
|
||||||
|
begin
|
||||||
|
Gitlab::GitalyClient::ServerService.new(@storage).info
|
||||||
|
rescue GRPC::Unavailable, GRPC::GRPC::DeadlineExceeded
|
||||||
|
# This will show the server as being out of date
|
||||||
|
Gitaly::ServerInfoResponse.new(git_version: '', server_version: '')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
module Gitlab
|
||||||
|
module GitalyClient
|
||||||
|
# Meant for extraction of server data, and later maybe to perform misc task
|
||||||
|
#
|
||||||
|
# Not meant for connection logic, look in Gitlab::GitalyClient
|
||||||
|
class ServerService
|
||||||
|
def initialize(storage)
|
||||||
|
@storage = storage
|
||||||
|
end
|
||||||
|
|
||||||
|
def info
|
||||||
|
GitalyClient.call(@storage, :server_service, :server_info, Gitaly::ServerInfoRequest.new)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Admin::GitalyServersController do
|
||||||
|
describe '#index' do
|
||||||
|
before do
|
||||||
|
sign_in(create(:admin))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows the gitaly servers page' do
|
||||||
|
get :index
|
||||||
|
|
||||||
|
expect(response).to have_gitlab_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,30 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Gitaly::Server do
|
||||||
|
describe '.all' do
|
||||||
|
let(:storages) { Gitlab.config.repositories.storages }
|
||||||
|
|
||||||
|
it 'includes all storages' do
|
||||||
|
expect(storages.count).to eq(described_class.all.count)
|
||||||
|
expect(storages.keys).to eq(described_class.all.map(&:storage))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { described_class.all.first }
|
||||||
|
|
||||||
|
it { is_expected.to respond_to(:server_version) }
|
||||||
|
it { is_expected.to respond_to(:git_binary_version) }
|
||||||
|
it { is_expected.to respond_to(:up_to_date?) }
|
||||||
|
it { is_expected.to respond_to(:address) }
|
||||||
|
|
||||||
|
describe 'request memoization' do
|
||||||
|
context 'when requesting multiple properties', :request_store do
|
||||||
|
it 'uses memoization for the info request' do
|
||||||
|
expect do
|
||||||
|
subject.server_version
|
||||||
|
subject.up_to_date?
|
||||||
|
end.to change { Gitlab::GitalyClient.get_request_count }.by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue