Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-03 15:09:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-03 15:09:49 +0300
commitd6533c44860930f866ae5abc967205e8eaf7e00c (patch)
tree1412675d5580fdb13c58ff1d7e3000e73bc791bd
parent119f0431e47b76f401dbb92d5774bf3380774038 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--GITALY_SERVER_VERSION2
-rw-r--r--app/assets/javascripts/boards/index.js16
-rw-r--r--app/assets/javascripts/sidebar/components/assignees/sidebar_assignees_widget.vue4
-rw-r--r--app/models/concerns/throttled_touch.rb2
-rw-r--r--app/models/note.rb2
-rw-r--r--app/views/shared/boards/components/sidebar/_assignee.html.haml3
-rw-r--r--changelogs/unreleased/329624-cannot-set-assignee-in-boards-view-for-self-managed-gitlab-with-re.yml6
-rw-r--r--changelogs/unreleased/sh-usage-data-ci-runners.yml5
-rw-r--r--config/initializers/active_record_preloader.rb2
-rw-r--r--config/metrics/counts_all/20210502045402_ci_runners_instance_type_active.yml21
-rw-r--r--config/metrics/counts_all/20210502050341_ci_runners_group_type_active.yml21
-rw-r--r--config/metrics/counts_all/20210502050834_ci_runners_project_type_active.yml21
-rw-r--r--config/metrics/counts_all/20210502050942_ci_runners_online.yml21
-rw-r--r--config/metrics/counts_all/20210502051651_ci_runners_instance_type_active_online.yml21
-rw-r--r--config/metrics/counts_all/20210502051922_ci_runners_group_type_active_online.yml21
-rw-r--r--config/metrics/counts_all/20210502052036_ci_runners_project_type_active_online.yml21
-rw-r--r--doc/development/usage_ping/dictionary.md84
-rw-r--r--lib/api/entities/environment.rb32
-rw-r--r--lib/gitlab/database/migration_helpers.rb16
-rw-r--r--lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb2
-rw-r--r--lib/gitlab/usage_data.rb14
-rw-r--r--locale/gitlab.pot3
-rw-r--r--package.json2
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/environment.json4
-rw-r--r--spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb2
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb23
-rw-r--r--spec/requests/api/environments_spec.rb69
-rw-r--r--yarn.lock8
28 files changed, 405 insertions, 43 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION
index 377a109f74c..ada363b4fbc 100644
--- a/GITALY_SERVER_VERSION
+++ b/GITALY_SERVER_VERSION
@@ -1 +1 @@
-08430e67d1673cbac3aa3e7d103e8e047e5b23c0
+d7c7ca994f16601bda8854ca9d20175dc8a11c74
diff --git a/app/assets/javascripts/boards/index.js b/app/assets/javascripts/boards/index.js
index e3f9d2f24c2..b13b04430c0 100644
--- a/app/assets/javascripts/boards/index.js
+++ b/app/assets/javascripts/boards/index.js
@@ -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;
diff --git a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees_widget.vue b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees_widget.vue
index 0d7c2d526ca..13e86c3316f 100644
--- a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees_widget.vue
+++ b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees_widget.vue
@@ -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>
diff --git a/app/models/concerns/throttled_touch.rb b/app/models/concerns/throttled_touch.rb
index 797c46f6cc5..b5682abb229 100644
--- a/app/models/concerns/throttled_touch.rb
+++ b/app/models/concerns/throttled_touch.rb
@@ -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
diff --git a/app/models/note.rb b/app/models/note.rb
index 13aa8fbfbd9..728393a6eca 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -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.
diff --git a/app/views/shared/boards/components/sidebar/_assignee.html.haml b/app/views/shared/boards/components/sidebar/_assignee.html.haml
index c36f2c7c969..8da8d567098 100644
--- a/app/views/shared/boards/components/sidebar/_assignee.html.haml
+++ b/app/views/shared/boards/components/sidebar/_assignee.html.haml
@@ -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" }
diff --git a/changelogs/unreleased/329624-cannot-set-assignee-in-boards-view-for-self-managed-gitlab-with-re.yml b/changelogs/unreleased/329624-cannot-set-assignee-in-boards-view-for-self-managed-gitlab-with-re.yml
new file mode 100644
index 00000000000..6192672babb
--- /dev/null
+++ b/changelogs/unreleased/329624-cannot-set-assignee-in-boards-view-for-self-managed-gitlab-with-re.yml
@@ -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
diff --git a/changelogs/unreleased/sh-usage-data-ci-runners.yml b/changelogs/unreleased/sh-usage-data-ci-runners.yml
new file mode 100644
index 00000000000..fa1174e2bb1
--- /dev/null
+++ b/changelogs/unreleased/sh-usage-data-ci-runners.yml
@@ -0,0 +1,5 @@
+---
+title: Add CI runner counts to usage ping
+merge_request: 58197
+author:
+type: added
diff --git a/config/initializers/active_record_preloader.rb b/config/initializers/active_record_preloader.rb
index 257a8a9e955..198c97cb849 100644
--- a/config/initializers/active_record_preloader.rb
+++ b/config/initializers/active_record_preloader.rb
@@ -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
diff --git a/config/metrics/counts_all/20210502045402_ci_runners_instance_type_active.yml b/config/metrics/counts_all/20210502045402_ci_runners_instance_type_active.yml
new file mode 100644
index 00000000000..2d42796514d
--- /dev/null
+++ b/config/metrics/counts_all/20210502045402_ci_runners_instance_type_active.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502050341_ci_runners_group_type_active.yml b/config/metrics/counts_all/20210502050341_ci_runners_group_type_active.yml
new file mode 100644
index 00000000000..49c99ce13ad
--- /dev/null
+++ b/config/metrics/counts_all/20210502050341_ci_runners_group_type_active.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502050834_ci_runners_project_type_active.yml b/config/metrics/counts_all/20210502050834_ci_runners_project_type_active.yml
new file mode 100644
index 00000000000..0c442466199
--- /dev/null
+++ b/config/metrics/counts_all/20210502050834_ci_runners_project_type_active.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502050942_ci_runners_online.yml b/config/metrics/counts_all/20210502050942_ci_runners_online.yml
new file mode 100644
index 00000000000..d661767095f
--- /dev/null
+++ b/config/metrics/counts_all/20210502050942_ci_runners_online.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502051651_ci_runners_instance_type_active_online.yml b/config/metrics/counts_all/20210502051651_ci_runners_instance_type_active_online.yml
new file mode 100644
index 00000000000..d5b2bb2eab8
--- /dev/null
+++ b/config/metrics/counts_all/20210502051651_ci_runners_instance_type_active_online.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502051922_ci_runners_group_type_active_online.yml b/config/metrics/counts_all/20210502051922_ci_runners_group_type_active_online.yml
new file mode 100644
index 00000000000..cedf120bfc1
--- /dev/null
+++ b/config/metrics/counts_all/20210502051922_ci_runners_group_type_active_online.yml
@@ -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
diff --git a/config/metrics/counts_all/20210502052036_ci_runners_project_type_active_online.yml b/config/metrics/counts_all/20210502052036_ci_runners_project_type_active_online.yml
new file mode 100644
index 00000000000..dbedcc7540d
--- /dev/null
+++ b/config/metrics/counts_all/20210502052036_ci_runners_project_type_active_online.yml
@@ -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
diff --git a/doc/development/usage_ping/dictionary.md b/doc/development/usage_ping/dictionary.md
index 9996d6eec87..034468441b7 100644
--- a/doc/development/usage_ping/dictionary.md
+++ b/doc/development/usage_ping/dictionary.md
@@ -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
diff --git a/lib/api/entities/environment.rb b/lib/api/entities/environment.rb
index 2928b04bacb..91867f3403d 100644
--- a/lib/api/entities/environment.rb
+++ b/lib/api/entities/environment.rb
@@ -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
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 874131f5155..1c10959c875 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -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
diff --git a/lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb b/lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb
index 0bc1343acca..c0cc97de276 100644
--- a/lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb
+++ b/lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb
@@ -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
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 8d4393e3acf..595e4181c06 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -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?
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 18351553c64..2f324a846d9 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -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 ""
diff --git a/package.json b/package.json
index e35243dacdc..3a1586a246b 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/spec/fixtures/api/schemas/public_api/v4/environment.json b/spec/fixtures/api/schemas/public_api/v4/environment.json
index dfb6e78cbda..b90bfe8de55 100644
--- a/spec/fixtures/api/schemas/public_api/v4/environment.json
+++ b/spec/fixtures/api/schemas/public_api/v4/environment.json
@@ -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
}
diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb
index 603f3dc41af..c3edc3a0c87 100644
--- a/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb
+++ b/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 42d502b9d23..8e0c79b3842 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -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 }
diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb
index e371dd7a043..5d40e8c529a 100644
--- a/spec/requests/api/environments_spec.rb
+++ b/spec/requests/api/environments_spec.rb
@@ -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) }
diff --git a/yarn.lock b/yarn.lock
index ee8ab91b018..e6ee7882021 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -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"