From b4e072cbaf808793bafff148b0ec9d47819f479e Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 11 Oct 2019 06:06:27 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/controllers/groups_controller.rb | 20 +-- app/models/clusters/applications/cert_manager.rb | 2 +- app/models/event.rb | 9 -- app/models/event_collection.rb | 43 ++++--- app/models/group.rb | 4 + app/views/groups/_activities.html.haml | 2 +- app/views/shared/_event_filter.html.haml | 4 + changelogs/unreleased/not_silent_retry_failure.yml | 5 + .../monitoring/prometheus/gitlab_exporter.md | 23 ++-- .../prometheus/gitlab_monitor_exporter.md | 5 + .../img/merge_request_pipeline.png | Bin 4394 -> 0 bytes .../img/merged_result_pipeline_v12_3.png | Bin 0 -> 28194 bytes .../pipelines_for_merged_results/index.md | 2 +- doc/ci/variables/predefined_variables.md | 4 +- doc/ci/yaml/README.md | 9 +- doc/development/architecture.md | 24 ++-- doc/development/changelog.md | 2 +- doc/development/database_debugging.md | 2 +- .../documentation/improvement-workflow.md | 2 +- doc/development/documentation/index.md | 28 ++--- doc/development/documentation/styleguide.md | 22 ++-- doc/development/elasticsearch.md | 7 +- doc/development/event_tracking/frontend.md | 6 +- doc/development/fe_guide/components.md | 2 +- doc/development/fe_guide/development_process.md | 2 +- doc/development/fe_guide/icons.md | 2 +- doc/development/fe_guide/performance.md | 23 ++-- doc/development/fe_guide/security.md | 2 +- doc/development/fe_guide/style_guide_js.md | 4 +- doc/development/feature_flags/controls.md | 4 +- doc/development/gitaly.md | 14 +-- doc/development/i18n/index.md | 2 +- doc/development/i18n/proofreader.md | 2 +- doc/development/i18n/translation.md | 4 +- doc/development/import_export.md | 2 +- doc/development/interacting_components.md | 2 +- doc/development/kubernetes.md | 5 +- .../new_fe_guide/development/components.md | 2 +- .../new_fe_guide/development/performance.md | 4 +- doc/development/sidekiq_style_guide.md | 2 +- doc/development/testing_guide/best_practices.md | 10 +- .../testing_guide/end_to_end/page_objects.md | 2 +- doc/development/testing_guide/flaky_tests.md | 2 +- doc/development/testing_guide/frontend_testing.md | 2 +- doc/development/testing_guide/review_apps.md | 4 +- doc/development/uploads.md | 18 +-- doc/user/project/deploy_tokens/index.md | 2 +- doc/user/project/merge_requests/index.md | 136 +-------------------- .../merge_requests/merge_request_approvals.md | 10 +- doc/user/project/push_options.md | 77 ++++++++++++ lib/event_filter.rb | 11 +- lib/gitlab/database.rb | 4 - lib/gitlab/kubernetes/helm/client_command.rb | 2 +- locale/gitlab.pot | 6 + scripts/lint-doc.sh | 4 +- spec/controllers/groups_controller_spec.rb | 2 +- spec/features/projects/features_visibility_spec.rb | 2 +- spec/lib/event_filter_spec.rb | 6 - spec/lib/gitlab/database_spec.rb | 14 --- .../gitlab/kubernetes/helm/delete_command_spec.rb | 4 +- .../gitlab/kubernetes/helm/install_command_spec.rb | 14 +-- .../clusters/applications/cert_manager_spec.rb | 2 +- spec/models/event_collection_spec.rb | 83 ++++++++----- 63 files changed, 347 insertions(+), 373 deletions(-) create mode 100644 changelogs/unreleased/not_silent_retry_failure.yml create mode 100644 doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md delete mode 100644 doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merge_request_pipeline.png create mode 100644 doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merged_result_pipeline_v12_3.png create mode 100644 doc/user/project/push_options.md diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 95a7876a055..3204e1e388b 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -198,15 +198,13 @@ class GroupsController < Groups::ApplicationController def load_events params[:sort] ||= 'latest_activity_desc' - options = {} - options[:include_subgroups] = true - - @projects = GroupProjectsFinder.new(params: params, group: group, options: options, current_user: current_user) - .execute - .includes(:namespace) + options = { include_subgroups: true } + projects = GroupProjectsFinder.new(params: params, group: group, options: options, current_user: current_user) + .execute + .includes(:namespace) @events = EventCollection - .new(@projects, offset: params[:offset].to_i, filter: event_filter) + .new(projects, offset: params[:offset].to_i, filter: event_filter, groups: groups) .to_a Events::RenderService @@ -228,6 +226,14 @@ class GroupsController < Groups::ApplicationController url_for(safe_params) end + + private + + def groups + if @group.supports_events? + @group.self_and_descendants.public_or_visible_to_user(current_user) + end + end end GroupsController.prepend_if_ee('EE::GroupsController') diff --git a/app/models/clusters/applications/cert_manager.rb b/app/models/clusters/applications/cert_manager.rb index 27d4180e5b9..2d71c4d5754 100644 --- a/app/models/clusters/applications/cert_manager.rb +++ b/app/models/clusters/applications/cert_manager.rb @@ -65,7 +65,7 @@ module Clusters end def retry_command(command) - "for i in $(seq 1 30); do #{command} && break; sleep 1s; echo \"Retrying ($i)...\"; done" + "for i in $(seq 1 30); do #{command} && break; sleep 1s; echo \"Retrying ($i)...\"; false; done" end def post_delete_script diff --git a/app/models/event.rb b/app/models/event.rb index 205e1f71c74..9611019adb8 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -77,15 +77,6 @@ class Event < ApplicationRecord scope :recent, -> { reorder(id: :desc) } scope :code_push, -> { where(action: PUSHED) } - scope :in_projects, -> (projects) do - sub_query = projects - .except(:order) - .select(1) - .where('projects.id = events.project_id') - - where('EXISTS (?)', sub_query).recent - end - scope :with_associations, -> do # We're using preload for "push_event_payload" as otherwise the association # is not always available (depending on the query being built). diff --git a/app/models/event_collection.rb b/app/models/event_collection.rb index a4c69b11781..4778f74568e 100644 --- a/app/models/event_collection.rb +++ b/app/models/event_collection.rb @@ -6,6 +6,8 @@ # in a controller), it's not suitable for building queries that are used for # building other queries. class EventCollection + include Gitlab::Utils::StrongMemoize + # To prevent users from putting too much pressure on the database by cycling # through thousands of events we put a limit on the number of pages. MAX_PAGE = 10 @@ -13,57 +15,52 @@ class EventCollection # projects - An ActiveRecord::Relation object that returns the projects for # which to retrieve events. # filter - An EventFilter instance to use for filtering events. - def initialize(projects, limit: 20, offset: 0, filter: nil) + def initialize(projects, limit: 20, offset: 0, filter: nil, groups: nil) @projects = projects @limit = limit @offset = offset @filter = filter + @groups = groups end # Returns an Array containing the events. def to_a return [] if current_page > MAX_PAGE - relation = if Gitlab::Database.join_lateral_supported? - relation_with_join_lateral + relation = if groups + project_and_group_events else - relation_without_join_lateral + relation_with_join_lateral('project_id', projects) end + relation = paginate_events(relation) relation.with_associations.to_a end private - # Returns the events relation to use when JOIN LATERAL is not supported. - # - # This relation simply gets all the events for all authorized projects, then - # limits that set. - def relation_without_join_lateral - events = filtered_events.in_projects(projects) + def project_and_group_events + project_events = relation_with_join_lateral('project_id', projects) + group_events = relation_with_join_lateral('group_id', groups) - paginate_events(events) + Event.from_union([project_events, group_events]).recent end - # Returns the events relation to use when JOIN LATERAL is supported. - # # This relation is built using JOIN LATERAL, producing faster queries than a # regular LIMIT + OFFSET approach. - def relation_with_join_lateral - projects_for_lateral = projects.select(:id).to_sql + def relation_with_join_lateral(parent_column, parents) + parents_for_lateral = parents.select(:id).to_sql lateral = filtered_events .limit(limit_for_join_lateral) - .where('events.project_id = projects_for_lateral.id') + .where("events.#{parent_column} = parents_for_lateral.id") # rubocop:disable GitlabSecurity/SqlInjection .to_sql # The outer query does not need to re-apply the filters since the JOIN # LATERAL body already takes care of this. - outer = base_relation - .from("(#{projects_for_lateral}) projects_for_lateral") + base_relation + .from("(#{parents_for_lateral}) parents_for_lateral") .joins("JOIN LATERAL (#{lateral}) AS #{Event.table_name} ON true") - - paginate_events(outer) end def filtered_events @@ -97,4 +94,10 @@ class EventCollection def projects @projects.except(:order) end + + def groups + strong_memoize(:groups) do + groups.except(:order) if @groups + end + end end diff --git a/app/models/group.rb b/app/models/group.rb index 5df9d97dcb6..0501fe94440 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -436,6 +436,10 @@ class Group < Namespace members.owners.order_recent_sign_in.limit(ACCESS_REQUEST_APPROVERS_TO_BE_NOTIFIED_LIMIT) end + def supports_events? + false + end + private def update_two_factor_requirement diff --git a/app/views/groups/_activities.html.haml b/app/views/groups/_activities.html.haml index 13df1e57125..44554cab1e9 100644 --- a/app/views/groups/_activities.html.haml +++ b/app/views/groups/_activities.html.haml @@ -1,5 +1,5 @@ .nav-block.activities - = render 'shared/event_filter' + = render 'shared/event_filter', show_group_events: @group.supports_events? .controls = link_to group_path(@group, rss_url_options), class: 'btn d-none d-sm-inline-block has-tooltip' , title: 'Subscribe' do %i.fa.fa-rss diff --git a/app/views/shared/_event_filter.html.haml b/app/views/shared/_event_filter.html.haml index 6612497e7e2..ad9eb325ff0 100644 --- a/app/views/shared/_event_filter.html.haml +++ b/app/views/shared/_event_filter.html.haml @@ -1,3 +1,5 @@ +- show_group_events = local_assigns.fetch(:show_group_events, false) + .scrolling-tabs-container.inner-page-scroll-tabs.is-smaller.flex-fill .fade-left= icon('angle-left') .fade-right= icon('angle-right') @@ -9,6 +11,8 @@ = event_filter_link EventFilter::MERGED, _('Merge events'), s_('EventFilterBy|Filter by merge events') - if event_filter_visible(:issues) = event_filter_link EventFilter::ISSUE, _('Issue events'), s_('EventFilterBy|Filter by issue events') + - if show_group_events + = render_if_exists 'events/epics_filter' - if comments_visible? = event_filter_link EventFilter::COMMENTS, _('Comments'), s_('EventFilterBy|Filter by comments') = event_filter_link EventFilter::TEAM, _('Team'), s_('EventFilterBy|Filter by team') diff --git a/changelogs/unreleased/not_silent_retry_failure.yml b/changelogs/unreleased/not_silent_retry_failure.yml new file mode 100644 index 00000000000..bccd046db7b --- /dev/null +++ b/changelogs/unreleased/not_silent_retry_failure.yml @@ -0,0 +1,5 @@ +--- +title: Stopped CRD apply retrying from allowing silent failures +merge_request: 18421 +author: +type: fixed diff --git a/doc/administration/monitoring/prometheus/gitlab_exporter.md b/doc/administration/monitoring/prometheus/gitlab_exporter.md index cfd9f55acc3..f6178799e0a 100644 --- a/doc/administration/monitoring/prometheus/gitlab_exporter.md +++ b/doc/administration/monitoring/prometheus/gitlab_exporter.md @@ -1,12 +1,16 @@ # GitLab exporter ->**Note:** -Available since [Omnibus GitLab 8.17][1132]. For installations from source -you'll have to install and configure it yourself. +>- Available since [Omnibus GitLab 8.17](https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/1132). +>- Renamed from `GitLab monitor exporter` to `GitLab exporter` in [GitLab 12.3](https://gitlab.com/gitlab-org/gitlab/merge_requests/16511). -The [GitLab exporter] allows you to measure various GitLab metrics, pulled from Redis and the database. +The [GitLab exporter](https://gitlab.com/gitlab-org/gitlab-exporter) allows you to +measure various GitLab metrics, pulled from Redis and the database, in Omnibus GitLab +instances. -To enable the GitLab exporter: +NOTE: **Note:** +For installations from source you'll have to install and configure it yourself. + +To enable the GitLab exporter in an Omnibus GitLab instance: 1. [Enable Prometheus](index.md#configuring-prometheus) 1. Edit `/etc/gitlab/gitlab.rb` @@ -16,15 +20,10 @@ To enable the GitLab exporter: gitlab_exporter['enable'] = true ``` -1. Save the file and [reconfigure GitLab][reconfigure] for the changes to - take effect +1. Save the file and [reconfigure GitLab](../../restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect Prometheus will now automatically begin collecting performance data from the GitLab exporter exposed under `localhost:9168`. [← Back to the main Prometheus page](index.md) - -[1132]: https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/1132 -[GitLab exporter]: https://gitlab.com/gitlab-org/gitlab-exporter -[prometheus]: https://prometheus.io -[reconfigure]: ../../restart_gitlab.md#omnibus-gitlab-reconfigure diff --git a/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md b/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md new file mode 100644 index 00000000000..ae3a3d739b5 --- /dev/null +++ b/doc/administration/monitoring/prometheus/gitlab_monitor_exporter.md @@ -0,0 +1,5 @@ +--- +redirect_to: 'gitlab_exporter.md' +--- + +This document was moved to [another location](gitlab_exporter.md). diff --git a/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merge_request_pipeline.png b/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merge_request_pipeline.png deleted file mode 100644 index 6d4b66824e1..00000000000 Binary files a/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merge_request_pipeline.png and /dev/null differ diff --git a/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merged_result_pipeline_v12_3.png b/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merged_result_pipeline_v12_3.png new file mode 100644 index 00000000000..6f0752bb940 Binary files /dev/null and b/doc/ci/merge_request_pipelines/pipelines_for_merged_results/img/merged_result_pipeline_v12_3.png differ diff --git a/doc/ci/merge_request_pipelines/pipelines_for_merged_results/index.md b/doc/ci/merge_request_pipelines/pipelines_for_merged_results/index.md index ced6efc415b..3a0848fcd08 100644 --- a/doc/ci/merge_request_pipelines/pipelines_for_merged_results/index.md +++ b/doc/ci/merge_request_pipelines/pipelines_for_merged_results/index.md @@ -20,7 +20,7 @@ GitLab can run pipelines for merge requests on this merged result. That is, where the source and target branches are combined into a new ref and a pipeline for this ref validates the result prior to merging. -![Merge request pipeline as the head pipeline](img/merge_request_pipeline.png) +![Merge request pipeline as the head pipeline](img/merged_result_pipeline_v12_3.png) There are some cases where creating a combined ref is not possible or not wanted. For example, a source branch that has conflicts with the target branch diff --git a/doc/ci/variables/predefined_variables.md b/doc/ci/variables/predefined_variables.md index 0fc15ac87e3..52f712abfae 100644 --- a/doc/ci/variables/predefined_variables.md +++ b/doc/ci/variables/predefined_variables.md @@ -60,12 +60,12 @@ future GitLab releases.** | `CI_MERGE_REQUEST_PROJECT_URL` | 11.6 | all | The URL of the project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md) (e.g. `http://192.168.10.15:3000/namespace/awesome-project`). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_REF_PATH` | 11.6 | all | The ref path of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). (e.g. `refs/merge-requests/1/head`). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME` | 11.6 | all | The source branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the source branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | +| `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the source branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | | `CI_MERGE_REQUEST_SOURCE_PROJECT_ID` | 11.6 | all | The ID of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_SOURCE_PROJECT_PATH` | 11.6 | all | The path of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_SOURCE_PROJECT_URL` | 11.6 | all | The URL of the source project of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_TARGET_BRANCH_NAME` | 11.6 | all | The target branch name of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | -| `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the target branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | +| `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` | 11.9 | all | The HEAD SHA of the target branch of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used, the merge request is created, and the pipeline is a [merged result pipeline](../merge_request_pipelines/pipelines_for_merged_results/index.md). **(PREMIUM)** | | `CI_MERGE_REQUEST_TITLE` | 11.9 | all | The title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_ASSIGNEES` | 11.9 | all | Comma-separated list of username(s) of assignee(s) for the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | | `CI_MERGE_REQUEST_MILESTONE` | 11.9 | all | The milestone title of the merge request if [the pipelines are for merge requests](../merge_request_pipelines/index.md). Available only if `only: [merge_requests]` is used and the merge request is created. | diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index a9f30a5ddd4..1a7c358eb91 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -3309,13 +3309,8 @@ all updated Merge Requests will have a pipeline created when using If your commit message contains `[ci skip]` or `[skip ci]`, using any capitalization, the commit will be created but the pipeline will be skipped. -Alternatively, one can pass the `ci.skip` [Git push option][push-option] if -using Git 2.10 or newer: - -```sh -git push --push-option=ci.skip # using git 2.10+ -git push -o ci.skip # using git 2.18+ -``` +Alternatively, one can pass the `ci.skip` [Git push option](../../user/project/push_options.md#push-options-for-gitlab-cicd) +if using Git 2.10 or newer.