Commit 03aae652 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'summit-challenge-hc' into 'master'

Summit challenge - health check

Closes #7345

See merge request gitlab-org/gitlab-ee!6995
parents a068d23c 10747e3e
......@@ -18,6 +18,8 @@
- if current_user_menu?(:help) || current_user_menu?(:settings) || current_user_menu?(:profile)
%li.divider
= render 'shared/user_dropdown_contributing_link'
- if instance_review_permitted?
= render 'shared/user_dropdown_instance_review'
- if current_user_menu?(:sign_out)
%li
= link_to _("Sign out"), destroy_user_session_path, class: "sign-out-link"
......@@ -24,6 +24,7 @@ namespace :admin do
## EE-specific
resource :push_rule, only: [:show, :update]
get :instance_review, to: 'instance_review#index'
## EE-specific
resource :impersonation, only: :destroy
......
# Instance Review
> [Introduced][6995] in [GitLab Core][ee] 11.3.
If you are running a medium size instance of GitLab Core edition you are qualified for a free Instance Review. You can find the button in the User menu.
![Instance Review button](img/instance_review_button.png)
When you click the button you will be redirected to a form with prefilled data obtained from your instance.
Once you submit the data to GitLab Inc. you can see the initial report.
Additionally you will be contacted by our team for further review which should help you to improve your usage of GitLab.
[6995]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6995
[ee]: https://about.gitlab.com/pricing/
# frozen_string_literal: true
class Admin::InstanceReviewController < Admin::ApplicationController
def index
redirect_to("#{EE::SUBSCRIPTIONS_URL}/instance_review?#{instance_review_params}")
end
def instance_review_params
result = {
instance_review: {
email: current_user.email,
last_name: current_user.name,
version: ::Gitlab::VERSION
}
}
if Gitlab::CurrentSettings.usage_ping_enabled?
data = ::Gitlab::UsageData.data
counts = data[:counts]
result[:instance_review].merge!(
users_count: data[:active_user_count],
projects_count: counts[:projects],
groups_count: counts[:groups],
issues_count: counts[:issues],
merge_requests_count: counts[:merge_requests],
internal_pipelines_count: counts[:ci_internal_pipelines],
external_pipelines_count: counts[:ci_external_pipelines],
labels_count: counts[:labels],
milestones_count: counts[:milestones],
snippets_count: counts[:snippets],
notes_count: counts[:notes]
)
end
result.to_query
end
end
......@@ -72,6 +72,10 @@ module EE
}
end
def instance_review_permitted?
::Gitlab::CurrentSettings.instance_review_permitted? && current_user&.admin?
end
private
def appearance
......
......@@ -10,6 +10,7 @@ module EE
include IgnorableColumn
EMAIL_ADDITIONAL_TEXT_CHARACTER_LIMIT = 10_000
INSTANCE_REVIEW_MIN_USERS = 100
belongs_to :file_template_project, class_name: "Project"
......@@ -193,6 +194,16 @@ module EE
::Project.where(namespace_id: group_id)
end
def instance_review_permitted?
return if License.current
users_count = Rails.cache.fetch('limited_users_count', expires_in: 1.day) do
::User.limit(INSTANCE_REVIEW_MIN_USERS + 1).count(:all)
end
users_count >= INSTANCE_REVIEW_MIN_USERS
end
private
def mirror_max_delay_in_minutes
......
%li
= link_to admin_instance_review_path, target: '_blank', class: 'text-nowrap' do
= _("Get a free instance review")
= sprite_icon('external-link', size: 16)
%li.divider
---
title: "Add Instance Review for Core users"
merge_request: 6995
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
describe Admin::InstanceReviewController do
let(:admin) { create(:admin) }
before do
sign_in(admin)
end
context 'GET #index' do
let!(:group) { create(:group) }
let!(:projects) { create_list(:project, 2, group: group) }
subject { post :index }
context 'with usage ping enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
::Gitlab::UsageData.data(force_refresh: true)
subject
end
it 'redirects to the customers app with correct params' do
params = { instance_review: {
email: admin.email,
last_name: admin.name,
version: ::Gitlab::VERSION,
users_count: 5,
projects_count: 2,
groups_count: 1,
issues_count: 0,
merge_requests_count: 0,
internal_pipelines_count: 0,
external_pipelines_count: 0,
labels_count: 0,
milestones_count: 0,
snippets_count: 0,
notes_count: 0
} }.to_query
expect(response).to redirect_to("#{EE::SUBSCRIPTIONS_URL}/instance_review?#{params}")
end
end
context 'with usage ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
subject
end
it 'redirects to the customers app with correct params' do
params = { instance_review: {
email: admin.email,
last_name: admin.name,
version: ::Gitlab::VERSION
} }.to_query
expect(response).to redirect_to("#{EE::SUBSCRIPTIONS_URL}/instance_review?#{params}")
end
end
end
end
......@@ -275,4 +275,45 @@ describe ApplicationSetting do
end
end
end
describe '#instance_review_permitted?' do
subject { setting.instance_review_permitted? }
context 'for instances with a valid license' do
before do
license = create(:license, plan: ::License::PREMIUM_PLAN)
allow(License).to receive(:current).and_return(license)
end
it 'is not permitted' do
expect(subject).to be_falsey
end
end
context 'for instances without a valid license' do
before do
allow(License).to receive(:current).and_return(nil)
end
context 'when there are more users than minimum count' do
before do
expect(Rails.cache).to receive(:fetch).and_return(101)
end
it 'is permitted' do
expect(subject).to be_truthy
end
end
context 'when there are less users than minimum count' do
before do
create(:user)
end
it 'is not permitted' do
expect(subject).to be_falsey
end
end
end
end
end
......@@ -3620,6 +3620,9 @@ msgstr ""
msgid "Geo|You need a different license to use Geo replication"
msgstr ""
msgid "Get a free instance review"
msgstr ""
msgid "Git"
msgstr ""
......
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