diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 15:07:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 15:07:40 +0300 |
commit | f864f8a7aafa45b0e4c04e4312f89da4b1227c0f (patch) | |
tree | e559b53ae6a7594f28409bab9d38325200b38495 | |
parent | 898e2cc1dfa88b4ac39cb4b35011f61b37f57b51 (diff) |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | .gitlab/ci/review.gitlab-ci.yml | 4 | ||||
-rw-r--r-- | app/models/deployment_metrics.rb | 10 | ||||
-rw-r--r-- | app/models/environment.rb | 8 | ||||
-rw-r--r-- | app/services/notes/create_service.rb | 14 | ||||
-rw-r--r-- | changelogs/unreleased/31475-fix-metrics-for-env-status.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/fix-group-transfer.yml | 5 | ||||
-rw-r--r-- | doc/administration/logs.md | 41 | ||||
-rw-r--r-- | doc/user/discussions/index.md | 5 | ||||
-rw-r--r-- | doc/user/project/quick_actions.md | 3 | ||||
-rw-r--r-- | doc/user/project/repository/index.md | 29 | ||||
-rw-r--r-- | lib/api/helpers.rb | 4 | ||||
-rw-r--r-- | locale/gitlab.pot | 9 | ||||
-rw-r--r-- | spec/models/deployment_metrics_spec.rb | 20 | ||||
-rw-r--r-- | spec/serializers/environment_status_entity_spec.rb | 2 |
14 files changed, 139 insertions, 20 deletions
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml index 11fef55d8f7..1062f6b03a4 100644 --- a/.gitlab/ci/review.gitlab-ci.yml +++ b/.gitlab/ci/review.gitlab-ci.yml @@ -23,11 +23,11 @@ build-qa-image: stage: prepare script: - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' - - export QA_MASTER_IMAGE="${CI_REGISTRY}/gitlab-org/gitlab/gitlab/gitlab-${GITLAB_EDITION}-qa:master" + - export QA_MASTER_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:master" - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}" + - echo "${CI_JOB_TOKEN}" | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY} - time docker pull "${QA_MASTER_IMAGE}" - time docker build --cache-from "${QA_MASTER_IMAGE}" --tag ${QA_IMAGE} --file ./qa/Dockerfile ./ - - echo "${CI_JOB_TOKEN}" | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY} - time docker push ${QA_IMAGE} .base-review-cleanup: diff --git a/app/models/deployment_metrics.rb b/app/models/deployment_metrics.rb index 2056c8bc59c..20f0ec3e9b6 100644 --- a/app/models/deployment_metrics.rb +++ b/app/models/deployment_metrics.rb @@ -13,18 +13,18 @@ class DeploymentMetrics end def has_metrics? - deployment.success? && prometheus_adapter&.can_query? + deployment.success? && prometheus_adapter&.configured? end def metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} end def additional_metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:additional_metrics_deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} @@ -47,4 +47,8 @@ class DeploymentMetrics def cluster_prometheus cluster.application_prometheus if cluster&.application_prometheus_available? end + + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 82bf0f9a615..84a72fee77b 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -208,7 +208,7 @@ class Environment < ApplicationRecord end def metrics - prometheus_adapter.query(:environment, self) if has_metrics? && prometheus_adapter.can_query? + prometheus_adapter.query(:environment, self) if has_metrics_and_can_query? end def prometheus_status @@ -216,7 +216,7 @@ class Environment < ApplicationRecord end def additional_metrics(*args) - return unless has_metrics? + return unless has_metrics_and_can_query? prometheus_adapter.query(:additional_metrics_environment, self, *args.map(&:to_f)) end @@ -285,6 +285,10 @@ class Environment < ApplicationRecord private + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end + def generate_slug self.slug = Gitlab::Slug::Environment.new(name).generate end diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index accfdb5b863..50dc98b88e9 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -4,9 +4,7 @@ module Notes class CreateService < ::Notes::BaseService # rubocop:disable Metrics/CyclomaticComplexity def execute - merge_request_diff_head_sha = params.delete(:merge_request_diff_head_sha) - - note = Notes::BuildService.new(project, current_user, params).execute + note = Notes::BuildService.new(project, current_user, params.except(:merge_request_diff_head_sha)).execute # n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/37440 note_valid = Gitlab::GitalyClient.allow_n_plus_1_calls do @@ -23,8 +21,7 @@ module Notes quick_actions_service = QuickActionsService.new(project, current_user) if quick_actions_service.supported?(note) - options = { merge_request_diff_head_sha: merge_request_diff_head_sha } - content, update_params, message = quick_actions_service.execute(note, options) + content, update_params, message = quick_actions_service.execute(note, quick_action_options) only_commands = content.empty? @@ -74,6 +71,11 @@ module Notes private + # EE::Notes::CreateService would override this method + def quick_action_options + { merge_request_diff_head_sha: params[:merge_request_diff_head_sha] } + end + def tracking_data_for(note) label = Gitlab.ee? && note.author == User.visual_review_bot ? 'anonymous_visual_review_note' : 'note' @@ -84,3 +86,5 @@ module Notes end end end + +Notes::CreateService.prepend_if_ee('EE::Notes::CreateService') diff --git a/changelogs/unreleased/31475-fix-metrics-for-env-status.yml b/changelogs/unreleased/31475-fix-metrics-for-env-status.yml new file mode 100644 index 00000000000..b063716e928 --- /dev/null +++ b/changelogs/unreleased/31475-fix-metrics-for-env-status.yml @@ -0,0 +1,5 @@ +--- +title: Prevent MergeRequestsController#ci_environment_status.json from making HTTP requests +merge_request: 21812 +author: +type: fixed diff --git a/changelogs/unreleased/fix-group-transfer.yml b/changelogs/unreleased/fix-group-transfer.yml new file mode 100644 index 00000000000..cf1787aa5af --- /dev/null +++ b/changelogs/unreleased/fix-group-transfer.yml @@ -0,0 +1,5 @@ +--- +title: Fix transferring groups to root when EE features are enabled +merge_request: 21915 +author: +type: fixed diff --git a/doc/administration/logs.md b/doc/administration/logs.md index f4a1c754252..fab37248134 100644 --- a/doc/administration/logs.md +++ b/doc/administration/logs.md @@ -421,6 +421,47 @@ etc. For example: {"severity":"DEBUG","time":"2019-10-17T06:23:13.227Z","correlation_id":null,"message":"redacted_search_result","class_name":"Milestone","id":2,"ability":"read_milestone","current_user_id":2,"query":"project"} ``` +## `exceptions_json.log` + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/17819) in GitLab 12.6. + +This file lives in +`/var/log/gitlab/gitlab-rails/exceptions_json.log` for Omnibus GitLab +packages or in `/home/git/gitlab/log/exceptions_json.log` for installations +from source. + +It logs the information about exceptions being tracked by `Gitlab::ErrorTracking` which provides standard and consistent way of [processing rescued exceptions](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/development/logging.md#exception-handling). + +Each line contains a JSON line that can be ingested by Elasticsearch. For example: + +```json +{ + "severity": "ERROR", + "time": "2019-12-17T11:49:29.485Z", + "correlation_id": "AbDVUrrTvM1", + "extra.server": { + "os": { + "name": "Darwin", + "version": "Darwin Kernel Version 19.2.0", + "build": "19.2.0", + }, + "runtime": { + "name": "ruby", + "version": "ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]" + } + }, + "extra.project_id": 55, + "extra.relation_key": "milestones", + "extra.relation_index": 1, + "exception.class": "NoMethodError", + "exception.message": "undefined method `strong_memoize' for #<Gitlab::ImportExport::RelationFactory:0x00007fb5d917c4b0>", + "exception.backtrace": [ + "lib/gitlab/import_export/relation_factory.rb:329:in `unique_relation?'", + "lib/gitlab/import_export/relation_factory.rb:345:in `find_or_create_object!'" + ] +} +``` + [repocheck]: repository_checks.md [Rack Attack]: ../security/rack_attack.md [Rate Limit]: ../user/admin_area/settings/rate_limits_on_raw_endpoints.md diff --git a/doc/user/discussions/index.md b/doc/user/discussions/index.md index d4e485d7c32..2eddd9e2ea3 100644 --- a/doc/user/discussions/index.md +++ b/doc/user/discussions/index.md @@ -352,7 +352,10 @@ bottom of the screen with two buttons: Clicking **Submit review** will publish all comments. Any quick actions submitted are performed at this time. -Alternatively, every pending comment has a button to finish the entire review. +Alternatively, to finish the entire review from a pending comment: + +- Click the **Finish review** button on the comment. +- Use the `/submit_review` [quick action](../project/quick_actions.md) in the text of non-review comment. ![Review submission](img/review_preview.png) diff --git a/doc/user/project/quick_actions.md b/doc/user/project/quick_actions.md index 97ae429a33f..a038dadd7e7 100644 --- a/doc/user/project/quick_actions.md +++ b/doc/user/project/quick_actions.md @@ -68,7 +68,8 @@ The following quick actions are applicable to descriptions, discussions and thre | `/remove_zoom` | ✓ | | | Remove Zoom meeting from this issue. ([Introduced in GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/merge_requests/16609)) | | `/target_branch <local branch name>` | | ✓ | | Set target branch | | `/wip` | | ✓ | | Toggle the Work In Progress status | -| `/approve` | | ✓ | | Approve the merge request | +| `/approve` | | ✓ | | Approve the merge request **(STARTER)** | +| `/submit_review` | | ✓ | | Submit a pending review. ([Introduced in GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/issues/8041)) **(PREMIUM)** | | `/merge` | | ✓ | | Merge (when pipeline succeeds) | | `/child_epic <epic>` | | | ✓ | Add child epic to `<epic>`. The `<epic>` value should be in the format of `&epic`, `group&epic`, or a URL to an epic. ([Introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab/issues/7330)) **(ULTIMATE)** | | `/remove_child_epic <epic>` | | | ✓ | Remove child epic from `<epic>`. The `<epic>` value should be in the format of `&epic`, `group&epic`, or a URL to an epic. ([Introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab/issues/7330)) **(ULTIMATE)** | diff --git a/doc/user/project/repository/index.md b/doc/user/project/repository/index.md index fc422bb5aba..fad8cbe81cb 100644 --- a/doc/user/project/repository/index.md +++ b/doc/user/project/repository/index.md @@ -116,6 +116,35 @@ rendered to HTML when viewed. Interactive features, including JavaScript plots, will not work when viewed in GitLab. +### OpenAPI viewer + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/19515) in GitLab 12.6. + +GitLab can render OpenAPI specification files with its file viewer, provided +their filenames include `openapi` or `swagger` and their extension is `yaml`, +`yml`, or `json`. The following examples are all correct: + +- `openapi.yml` +- `openapi.yaml` +- `openapi.json` +- `swagger.yml` +- `swagger.yaml` +- `swagger.json` +- `gitlab_swagger.yml` +- `openapi_gitlab.yml` +- `OpenAPI.YML` +- `openapi.Yaml` +- `openapi.JSON` +- `openapi.gitlab.yml` +- `gitlab.openapi.yml` + +Then, to render them: + +1. Navigate to the OpenAPI file in your repository in GitLab's UI. +1. Click the "Display OpenAPI" button which is located between the "Display source" + and "Edit" buttons (when an OpenAPI file is found, it replaces the + "Display rendered file" button). + ## Branches For details, see [Branches](branches/index.md). diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 37cb6d6a639..bb61b4948b9 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -363,6 +363,10 @@ module API render_api_error!('204 No Content', 204) end + def created! + render_api_error!('201 Created', 201) + end + def accepted! render_api_error!('202 Accepted', 202) end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index cef7a6896dc..71ab65e84f6 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -17283,6 +17283,9 @@ msgstr "" msgid "Subkeys" msgstr "" +msgid "Submit a review" +msgstr "" + msgid "Submit as spam" msgstr "" @@ -17298,6 +17301,12 @@ msgstr "" msgid "Submit search" msgstr "" +msgid "Submit the current review." +msgstr "" + +msgid "Submitted the current review." +msgstr "" + msgid "Subscribe" msgstr "" diff --git a/spec/models/deployment_metrics_spec.rb b/spec/models/deployment_metrics_spec.rb index 7c574a8b6c8..32c04e15b73 100644 --- a/spec/models/deployment_metrics_spec.rb +++ b/spec/models/deployment_metrics_spec.rb @@ -20,7 +20,7 @@ describe DeploymentMetrics do end context 'with a Prometheus Service' do - let(:prometheus_service) { instance_double(PrometheusService, can_query?: true) } + let(:prometheus_service) { instance_double(PrometheusService, can_query?: true, configured?: true) } before do allow(deployment.project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service @@ -30,7 +30,17 @@ describe DeploymentMetrics do end context 'with a Prometheus Service that cannot query' do - let(:prometheus_service) { instance_double(PrometheusService, can_query?: false) } + let(:prometheus_service) { instance_double(PrometheusService, configured?: true, can_query?: false) } + + before do + allow(deployment.project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service + end + + it { is_expected.to be_falsy } + end + + context 'with a Prometheus Service that is not configured' do + let(:prometheus_service) { instance_double(PrometheusService, configured?: false, can_query?: false) } before do allow(deployment.project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service @@ -44,7 +54,7 @@ describe DeploymentMetrics do let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: deployment.cluster) } before do - expect(deployment.cluster.application_prometheus).to receive(:can_query?).and_return(true) + expect(deployment.cluster.application_prometheus).to receive(:configured?).and_return(true) end it { is_expected.to be_truthy } @@ -54,7 +64,7 @@ describe DeploymentMetrics do describe '#metrics' do let(:deployment) { create(:deployment, :success) } - let(:prometheus_adapter) { instance_double(PrometheusService, can_query?: true) } + let(:prometheus_adapter) { instance_double(PrometheusService, can_query?: true, configured?: true) } let(:deployment_metrics) { described_class.new(deployment.project, deployment) } subject { deployment_metrics.metrics } @@ -101,7 +111,7 @@ describe DeploymentMetrics do } end - let(:prometheus_adapter) { instance_double('prometheus_adapter', can_query?: true) } + let(:prometheus_adapter) { instance_double('prometheus_adapter', can_query?: true, configured?: true) } before do allow(deployment_metrics).to receive(:prometheus_adapter).and_return(prometheus_adapter) diff --git a/spec/serializers/environment_status_entity_spec.rb b/spec/serializers/environment_status_entity_spec.rb index 6d98f91cfde..11455c57677 100644 --- a/spec/serializers/environment_status_entity_spec.rb +++ b/spec/serializers/environment_status_entity_spec.rb @@ -45,7 +45,7 @@ describe EnvironmentStatusEntity do end context 'when deployment has metrics' do - let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) } + let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true, configured?: true) } let(:simple_metrics) do { |