Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-05-03 12:09:49 +00:00
parent 119f0431e4
commit d6533c4486
28 changed files with 405 additions and 43 deletions

View File

@ -1 +1 @@
08430e67d1673cbac3aa3e7d103e8e047e5b23c0
d7c7ca994f16601bda8854ca9d20175dc8a11c74

View File

@ -1,3 +1,4 @@
import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { mapActions, mapGetters } from 'vuex';
@ -35,13 +36,26 @@ import {
} from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import sidebarEventHub from '~/sidebar/event_hub';
import introspectionQueryResultData from '~/sidebar/fragmentTypes.json';
import boardConfigToggle from './config_toggle';
import mountMultipleBoardsSwitcher from './mount_multiple_boards_switcher';
Vue.use(VueApollo);
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData,
});
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
defaultClient: createDefaultClient(
{},
{
cacheConfig: {
fragmentMatcher,
},
assumeImmutableResults: true,
},
),
});
let issueBoardsApp;

View File

@ -245,8 +245,8 @@ export default {
@input="setDirtyState"
>
<template #footer>
<gl-dropdown-item>
<sidebar-invite-members v-if="directlyInviteMembers" />
<gl-dropdown-item v-if="directlyInviteMembers">
<sidebar-invite-members />
</gl-dropdown-item> </template
></user-select>
</template>

View File

@ -6,7 +6,7 @@ module ThrottledTouch
# The amount of time to wait before "touch" can update a record again.
TOUCH_INTERVAL = 1.minute
def touch(*args)
def touch(*args, **kwargs)
super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
end
end

View File

@ -495,7 +495,7 @@ class Note < ApplicationRecord
noteable&.expire_note_etag_cache
end
def touch(*args)
def touch(*args, **kwargs)
# We're not using an explicit transaction here because this would in all
# cases result in all future queries going to the primary, even if no writes
# are performed.

View File

@ -1,9 +1,10 @@
- dropdown_options = assignees_dropdown_options('issue')
- relative_url = Gitlab.config.gitlab.relative_url_root || '/'
.block.assignee{ ref: "assigneeBlock" }
%template{ "v-if" => "issue.assignees" }
%sidebar-assignees-widget{ ":iid" => "String(issue.iid)",
":full-path" => "issue.path.split('/-/')[0].substring(1)",
":full-path" => "issue.path.split('/-/')[0].substring(1).replace(`#{relative_url}`, '')",
":initial-assignees" => "issue.assignees",
":multiple-assignees" => "!Boolean(#{dropdown_options[:data][:"max-select"]})",
"@assignees-updated" => "setAssignees" }

View File

@ -0,0 +1,6 @@
---
title: Resolve Cannot Set Assignee in Boards View for self-managed GitLab with Relative
URL
merge_request: 60711
author:
type: fixed

View File

@ -0,0 +1,5 @@
---
title: Add CI runner counts to usage ping
merge_request: 58197
author:
type: added

View File

@ -4,7 +4,7 @@ module ActiveRecord
module Associations
class Preloader
class NullPreloader
def self.new(klass, owners, reflection, preload_scope)
def self.new(*args, **kwargs)
self
end

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_instance_type_active
name: "count_active_instance_ci_runners"
description: Total active group Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_group_type_active
name: "count_active_group_ci_runners"
description: Total active instance Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_project_type_active
name: "count_active_project_ci_runners"
description: Total active project Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_online
name: "counts_online_runners"
description: Total online Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_instance_type_active_online
name: "count_instance_active_online_ci_runners"
description: Total active and online instance Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_group_type_active_online
name: "count_group_active_online_ci_runners"
description: Total active and online group Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,21 @@
---
key_path: counts.ci_runners_project_type_active_online
name: "count_project_active_online_ci_runners"
description: Total active and online project Runners
product_section: ops
product_stage: verify
product_group: group::continuous integration
product_category: continuous_integration
value_type: number
status: implemented
milestone: "13.12"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58197
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -560,6 +560,90 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_group_type_active`
Total active instance Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502050341_ci_runners_group_type_active.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_group_type_active_online`
Total active and online group Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502051922_ci_runners_group_type_active_online.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_instance_type_active`
Total active group Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502045402_ci_runners_instance_type_active.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_instance_type_active_online`
Total active and online instance Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502051651_ci_runners_instance_type_active_online.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_online`
Total online Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502050942_ci_runners_online.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_project_type_active`
Total active project Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502050834_ci_runners_project_type_active.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_runners_project_type_active_online`
Total active and online project Runners
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210502052036_ci_runners_project_type_active_online.yml)
Group: `group::continuous integration`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.ci_triggers`
Total configured Triggers in project

View File

@ -3,21 +3,43 @@
module API
module Entities
class Environment < Entities::EnvironmentBasic
include RequestAwareEntity
include Gitlab::Utils::StrongMemoize
expose :project, using: Entities::BasicProjectDetails
expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true }
expose :state
expose :enable_advanced_logs_querying, if: ->(_, _) { can_read_pod_logs? }
expose :enable_advanced_logs_querying, if: -> (*) { can_read_pod_logs? } do |environment|
environment.elastic_stack_available?
end
expose :logs_api_path, if: -> (*) { can_read_pod_logs? } do |environment|
if environment.elastic_stack_available?
elasticsearch_project_logs_path(environment.project, environment_name: environment.name, format: :json)
else
k8s_project_logs_path(environment.project, environment_name: environment.name, format: :json)
end
end
expose :gitlab_managed_apps_logs_path, if: -> (*) { can_read_pod_logs? && cluster } do |environment|
::Clusters::ClusterPresenter.new(cluster, current_user: current_user).gitlab_managed_apps_logs_path # rubocop: disable CodeReuse/Presenter
end
private
alias_method :environment, :object
def enable_advanced_logs_querying
environment.elastic_stack_available?
def can_read_pod_logs?
strong_memoize(:can_read_pod_logs) do
current_user&.can?(:read_pod_logs, environment.project)
end
end
def can_read_pod_logs?
current_user&.can?(:read_pod_logs, environment.project)
def cluster
strong_memoize(:cluster) do
environment&.last_deployment&.cluster
end
end
def current_user

View File

@ -51,7 +51,7 @@ module Gitlab
allow_null: options[:null]
)
else
add_column(table_name, column_name, :datetime_with_timezone, options)
add_column(table_name, column_name, :datetime_with_timezone, **options)
end
end
end
@ -143,13 +143,13 @@ module Gitlab
options = options.merge({ algorithm: :concurrently })
if index_exists?(table_name, column_name, options)
if index_exists?(table_name, column_name, **options)
Gitlab::AppLogger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return
end
disable_statement_timeout do
add_index(table_name, column_name, options)
add_index(table_name, column_name, **options)
end
end
@ -169,13 +169,13 @@ module Gitlab
options = options.merge({ algorithm: :concurrently })
unless index_exists?(table_name, column_name, options)
unless index_exists?(table_name, column_name, **options)
Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return
end
disable_statement_timeout do
remove_index(table_name, options.merge({ column: column_name }))
remove_index(table_name, **options.merge({ column: column_name }))
end
end
@ -205,7 +205,7 @@ module Gitlab
end
disable_statement_timeout do
remove_index(table_name, options.merge({ name: index_name }))
remove_index(table_name, **options.merge({ name: index_name }))
end
end
@ -1194,8 +1194,8 @@ module Gitlab
end
end
def remove_foreign_key_without_error(*args)
remove_foreign_key(*args)
def remove_foreign_key_without_error(*args, **kwargs)
remove_foreign_key(*args, **kwargs)
rescue ArgumentError
end

View File

@ -40,7 +40,7 @@ module Gitlab
end
with_lock_retries do
add_index(table_name, column_names, options)
add_index(table_name, column_names, **options)
end
end

View File

@ -98,7 +98,6 @@ module Gitlab
ci_external_pipelines: count(::Ci::Pipeline.external),
ci_pipeline_config_auto_devops: count(::Ci::Pipeline.auto_devops_source),
ci_pipeline_config_repository: count(::Ci::Pipeline.repository_source),
ci_runners: count(::Ci::Runner),
ci_triggers: count(::Ci::Trigger),
ci_pipeline_schedules: count(::Ci::PipelineSchedule),
auto_devops_enabled: count(::ProjectAutoDevops.enabled),
@ -185,6 +184,7 @@ module Gitlab
merge_requests: count(MergeRequest),
notes: count(Note)
}.merge(
runners_usage,
services_usage,
usage_counters,
user_preferences_usage,
@ -198,6 +198,18 @@ module Gitlab
end
# rubocop: enable Metrics/AbcSize
def runners_usage
{
ci_runners: count(::Ci::Runner),
ci_runners_instance_type_active: count(::Ci::Runner.instance_type.active),
ci_runners_group_type_active: count(::Ci::Runner.group_type.active),
ci_runners_project_type_active: count(::Ci::Runner.project_type.active),
ci_runners_instance_type_active_online: count(::Ci::Runner.instance_type.active.online),
ci_runners_group_type_active_online: count(::Ci::Runner.group_type.active.online),
ci_runners_project_type_active_online: count(::Ci::Runner.project_type.active.online)
}
end
def snowplow_event_counts(time_period)
return {} unless report_snowplow_events?

View File

@ -31868,6 +31868,9 @@ msgstr ""
msgid "The group will be placed in 'pending removal' state"
msgstr ""
msgid "The group_project_ids parameter is only allowed for a group"
msgstr ""
msgid "The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination."
msgstr ""

View File

@ -232,7 +232,7 @@
"markdownlint-cli": "0.26.0",
"md5": "^2.2.1",
"miragejs": "^0.1.40",
"mock-apollo-client": "^0.5.0",
"mock-apollo-client": "^0.7.0",
"nodemon": "^2.0.4",
"postcss": "^7.0.14",
"prettier": "2.2.1",

View File

@ -19,7 +19,9 @@
]
},
"state": { "type": "string" },
"enable_advanced_logs_querying": { "type": "boolean" }
"enable_advanced_logs_querying": { "type": "boolean" },
"logs_api_path": { "type": "string" },
"gitlab_managed_apps_logs_path": { "type": "string" }
},
"additionalProperties": false
}

View File

@ -64,7 +64,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::IndexHelpers do
def expect_add_concurrent_index_and_call_original(table, column, index)
expect(migration).to receive(:add_concurrent_index).ordered.with(table, column, name: index)
.and_wrap_original { |_, table, column, options| connection.add_index(table, column, options) }
.and_wrap_original { |_, table, column, options| connection.add_index(table, column, **options) }
end
end

View File

@ -744,6 +744,29 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe '.runners_usage' do
before do
project = build(:project)
create_list(:ci_runner, 2, :instance_type, :online)
create(:ci_runner, :group, :online)
create(:ci_runner, :group, :inactive)
create_list(:ci_runner, 3, :project_type, :online, projects: [project])
end
subject { described_class.runners_usage }
it 'gathers runner usage counts correctly' do
expect(subject[:ci_runners]).to eq(7)
expect(subject[:ci_runners_instance_type_active]).to eq(2)
expect(subject[:ci_runners_group_type_active]).to eq(1)
expect(subject[:ci_runners_project_type_active]).to eq(3)
expect(subject[:ci_runners_instance_type_active_online]).to eq(2)
expect(subject[:ci_runners_group_type_active_online]).to eq(1)
expect(subject[:ci_runners_project_type_active_online]).to eq(3)
end
end
describe '.usage_counters' do
subject { described_class.usage_counters }

View File

@ -12,7 +12,7 @@ RSpec.describe API::Environments do
project.add_maintainer(user)
end
describe 'GET /projects/:id/environments' do
describe 'GET /projects/:id/environments', :aggregate_failures do
context 'as member of the project' do
it 'returns project environments' do
get api("/projects/#{project.id}/environments", user)
@ -26,17 +26,34 @@ RSpec.describe API::Environments do
expect(json_response.first['project']).to match_schema('public_api/v4/project')
expect(json_response.first['enable_advanced_logs_querying']).to eq(false)
expect(json_response.first).not_to have_key('last_deployment')
expect(json_response.first).not_to have_key('gitlab_managed_apps_logs_path')
end
context 'when elastic stack is available' do
before do
allow_next_found_instance_of(Environment) do |env|
allow(env).to receive(:elastic_stack_available?).and_return(true)
context 'when the user can read pod logs' do
context 'with successful deployment on cluster' do
let_it_be(:deployment) { create(:deployment, :on_cluster, :success, environment: environment, project: project) }
it 'returns environment with enable_advanced_logs_querying and logs_api_path' do
get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first['gitlab_managed_apps_logs_path']).to eq(
"/#{project.full_path}/-/logs/k8s.json?cluster_id=#{deployment.cluster_id}"
)
end
end
context 'when the user can read pod logs' do
it 'returns environment with enable_advanced_logs_querying' do
context 'when elastic stack is available' do
before do
allow_next_found_instance_of(Environment) do |env|
allow(env).to receive(:elastic_stack_available?).and_return(true)
end
end
it 'returns environment with enable_advanced_logs_querying and logs_api_path' do
get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(:ok)
@ -44,29 +61,55 @@ RSpec.describe API::Environments do
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first['enable_advanced_logs_querying']).to eq(true)
expect(json_response.first['logs_api_path']).to eq(
"/#{project.full_path}/-/logs/elasticsearch.json?environment_name=#{environment.name}"
)
end
end
context 'when the user cannot read pod logs' do
context 'when elastic stack is not available' do
before do
allow_next_found_instance_of(User) do |user|
allow(user).to receive(:can?).and_call_original
allow(user).to receive(:can?).with(:read_pod_logs, project).and_return(false)
allow_next_found_instance_of(Environment) do |env|
allow(env).to receive(:elastic_stack_available?).and_return(false)
end
end
it 'does not contain enable_advanced_logs_querying' do
it 'returns environment with enable_advanced_logs_querying logs_api_path' do
get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first).not_to have_key('enable_advanced_logs_querying')
expect(json_response.first['enable_advanced_logs_querying']).to eq(false)
expect(json_response.first['logs_api_path']).to eq(
"/#{project.full_path}/-/logs/k8s.json?environment_name=#{environment.name}"
)
end
end
end
context 'when the user cannot read pod logs' do
before do
allow_next_found_instance_of(User) do |user|
allow(user).to receive(:can?).and_call_original
allow(user).to receive(:can?).with(:read_pod_logs, project).and_return(false)
end
end
it 'does not contain enable_advanced_logs_querying' do
get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first).not_to have_key('enable_advanced_logs_querying')
expect(json_response.first).not_to have_key('logs_api_path')
expect(json_response.first).not_to have_key('gitlab_managed_apps_logs_path')
end
end
context 'when filtering' do
let_it_be(:environment2) { create(:environment, project: project) }

View File

@ -8454,10 +8454,10 @@ mkdirp@^1.0.3, mkdirp@^1.0.4, mkdirp@~1.0.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
mock-apollo-client@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/mock-apollo-client/-/mock-apollo-client-0.5.0.tgz#8f0d6a1ba0d349ebde87a1dcd85c7fd353076922"
integrity sha512-qdMUt1NhmNXLjHd/IaHbvbX5LaEE91WZB4glfj7AfUUs413/z148kBuXKg6XpMZqvJr+XdR/9i1V+YGY7UnCKA==
mock-apollo-client@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/mock-apollo-client/-/mock-apollo-client-0.7.0.tgz#5f70e75c842a9f3b3da2252f68fd47f2d9955f77"
integrity sha512-r0ICU01m007W0MwMej0lzlg1REtepDZ15Fyj8Hz9tiW/1TPb0PyHryGykrg9YhfbB8/+ZF2ovz+88yMF75TDoA==
moment-mini@^2.22.1:
version "2.22.1"