From 9345f69894862e02f3491ea3136c3ed2b23fd5b8 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 17 Mar 2020 03:09:27 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- Gemfile | 2 +- Gemfile.lock | 4 +-- app/models/project.rb | 8 +++++- app/models/repository.rb | 3 +- .../pokstad1-remove-branch-user-squash.yml | 5 ++++ .../sh-ensure-fresh-project-settings.yml | 5 ++++ doc/ci/interactive_web_terminal/index.md | 2 +- doc/development/documentation/styleguide.md | 16 ++++++++--- doc/development/import_export.md | 4 +-- lib/gitlab/git/repository.rb | 5 ++-- lib/gitlab/gitaly_client/operation_service.rb | 3 +- .../project/create_service_spec.rb | 28 +++++++++++-------- .../gitaly_client/operation_service_spec.rb | 4 +-- spec/models/project_spec.rb | 16 +++++++++++ 14 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 changelogs/unreleased/pokstad1-remove-branch-user-squash.yml create mode 100644 changelogs/unreleased/sh-ensure-fresh-project-settings.yml diff --git a/Gemfile b/Gemfile index 1e01266155e..51350401807 100644 --- a/Gemfile +++ b/Gemfile @@ -456,7 +456,7 @@ group :ed25519 do end # Gitaly GRPC protocol definitions -gem 'gitaly', '~> 1.86.0' +gem 'gitaly', '~> 12.9.0.pre.rc4' gem 'grpc', '~> 1.24.0' diff --git a/Gemfile.lock b/Gemfile.lock index 6da9a9a1740..8006e45259a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -366,7 +366,7 @@ GEM po_to_json (>= 1.0.0) rails (>= 3.2.0) git (1.5.0) - gitaly (1.86.0) + gitaly (12.9.0.pre.rc4) grpc (~> 1.0) github-markup (1.7.0) gitlab-chronic (0.10.5) @@ -1228,7 +1228,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.3) - gitaly (~> 1.86.0) + gitaly (~> 12.9.0.pre.rc4) github-markup (~> 1.7.0) gitlab-chronic (~> 0.10.5) gitlab-derailed_benchmarks diff --git a/app/models/project.rb b/app/models/project.rb index 4017fe31b84..8578cd0e44a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -66,7 +66,13 @@ class Project < ApplicationRecord default_value_for :archived, false default_value_for :resolve_outdated_diff_discussions, false default_value_for :container_registry_enabled, gitlab_config_features.container_registry - default_value_for(:repository_storage) { Gitlab::CurrentSettings.pick_repository_storage } + default_value_for(:repository_storage) do + # We need to ensure application settings are fresh when we pick + # a repository storage to use. + Gitlab::CurrentSettings.expire_current_application_settings + Gitlab::CurrentSettings.pick_repository_storage + end + default_value_for(:shared_runners_enabled) { Gitlab::CurrentSettings.shared_runners_enabled } default_value_for :issues_enabled, gitlab_config_features.issues default_value_for :merge_requests_enabled, gitlab_config_features.merge_requests diff --git a/app/models/repository.rb b/app/models/repository.rb index 5603c35b419..a9ef0504a3d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1061,8 +1061,7 @@ class Repository end def squash(user, merge_request, message) - raw.squash(user, merge_request.id, branch: merge_request.target_branch, - start_sha: merge_request.diff_start_sha, + raw.squash(user, merge_request.id, start_sha: merge_request.diff_start_sha, end_sha: merge_request.diff_head_sha, author: merge_request.author, message: message) diff --git a/changelogs/unreleased/pokstad1-remove-branch-user-squash.yml b/changelogs/unreleased/pokstad1-remove-branch-user-squash.yml new file mode 100644 index 00000000000..60efd000094 --- /dev/null +++ b/changelogs/unreleased/pokstad1-remove-branch-user-squash.yml @@ -0,0 +1,5 @@ +--- +title: Upgrade Gitaly gem and fix UserSquash RPC usage +merge_request: 27372 +author: +type: other diff --git a/changelogs/unreleased/sh-ensure-fresh-project-settings.yml b/changelogs/unreleased/sh-ensure-fresh-project-settings.yml new file mode 100644 index 00000000000..9b37d06f75b --- /dev/null +++ b/changelogs/unreleased/sh-ensure-fresh-project-settings.yml @@ -0,0 +1,5 @@ +--- +title: Ensure freshness of settings with project creation +merge_request: 27156 +author: +type: fixed diff --git a/doc/ci/interactive_web_terminal/index.md b/doc/ci/interactive_web_terminal/index.md index f7e8a0e412c..661e32b1571 100644 --- a/doc/ci/interactive_web_terminal/index.md +++ b/doc/ci/interactive_web_terminal/index.md @@ -15,7 +15,7 @@ taken to protect the users. NOTE: **Note:** [Shared runners on GitLab.com](../quick_start/README.md#shared-runners) do not provide an interactive web terminal. Follow [this -issue](https://gitlab.com/gitlab-org/gitlab-foss/issues/52611) for progress on +issue](https://gitlab.com/gitlab-org/gitlab/-/issues/24674) for progress on adding support. For groups and projects hosted on GitLab.com, interactive web terminals are available when using your own group or project runner. diff --git a/doc/development/documentation/styleguide.md b/doc/development/documentation/styleguide.md index 2ae3cd0a290..d031364964d 100644 --- a/doc/development/documentation/styleguide.md +++ b/doc/development/documentation/styleguide.md @@ -628,8 +628,17 @@ do not use this option until further notice. ### Links to internal documentation -- To link to internal documentation, use relative links, not absolute URLs. - Use `../` to navigate to high-level directories. Links should not refer to root. +NOTE: **Note:** +_Internal_ refers to documentation in the same project. When linking to documentation in +separate projects (for example, linking to Omnibus docs from GitLab docs), you must use absolute +URLs. + +To link to internal documentation: + +- Use relative links to Markdown files in the same repository. +- Do not use absolute URLs or URLs from `docs.gitlab.com`. +- Use `../` to navigate to higher-level directories. +- Do not link relative to root. For example, `/ee/user/gitlab_com/index.md`. Don't: @@ -652,8 +661,7 @@ do not use this option until further notice. - `../../issues/tags.md` - `../../issues/tags.md#stages` -- Using the Markdown extension is necessary for the [`/help`](index.md#gitlab-help) - section of GitLab. +- Use the Markdown extension for the [`/help`](index.md#gitlab-help) section of GitLab. ### Links requiring permissions diff --git a/doc/development/import_export.md b/doc/development/import_export.md index 68f7b78337d..9dde5422642 100644 --- a/doc/development/import_export.md +++ b/doc/development/import_export.md @@ -79,11 +79,11 @@ Marked stuck import jobs as failed. JIDs: xyz | Problem | Possible solutions | | -------- | -------- | -| [Slow JSON](https://gitlab.com/gitlab-org/gitlab-foss/issues/54084) loading/dumping models from the database | [split the worker](https://gitlab.com/gitlab-org/gitlab-foss/issues/54085) | +| [Slow JSON](https://gitlab.com/gitlab-org/gitlab/-/issues/25251) loading/dumping models from the database | [split the worker](https://gitlab.com/gitlab-org/gitlab/-/issues/25252) | | | Batch export | | Optimize SQL | | Move away from `ActiveRecord` callbacks (difficult) -| High memory usage (see also some [analysis](https://gitlab.com/gitlab-org/gitlab-foss/issues/35389) | DB Commit sweet spot that uses less memory | +| High memory usage (see also some [analysis](https://gitlab.com/gitlab-org/gitlab/-/issues/18857) | DB Commit sweet spot that uses less memory | | | [Netflix Fast JSON API](https://github.com/Netflix/fast_jsonapi) may help | | | Batch reading/writing to disk and any SQL diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index fd31039491a..6e2e664fc52 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -842,10 +842,9 @@ module Gitlab end end - def squash(user, squash_id, branch:, start_sha:, end_sha:, author:, message:) + def squash(user, squash_id, start_sha:, end_sha:, author:, message:) wrapped_gitaly_errors do - gitaly_operation_client.user_squash(user, squash_id, branch, - start_sha, end_sha, author, message) + gitaly_operation_client.user_squash(user, squash_id, start_sha, end_sha, author, message) end end diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index 67fb0ab9608..9ed4b2da09a 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -248,12 +248,11 @@ module Gitlab request_enum.close end - def user_squash(user, squash_id, branch, start_sha, end_sha, author, message) + def user_squash(user, squash_id, start_sha, end_sha, author, message) request = Gitaly::UserSquashRequest.new( repository: @gitaly_repo, user: Gitlab::Git::User.from_gitlab(user).to_gitaly, squash_id: squash_id.to_s, - branch: encode_binary(branch), start_sha: start_sha, end_sha: end_sha, author: Gitlab::Git::User.from_gitlab(author).to_gitaly, diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb index 0b8f64e97a1..923f620a81d 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb @@ -50,7 +50,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do end end - context 'with application settings and admin users' do + context 'with application settings and admin users', :request_store do let(:project) { result[:project] } let(:group) { result[:group] } let(:application_setting) { Gitlab::CurrentSettings.current_application_settings } @@ -58,8 +58,9 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do let!(:user) { create(:user, :admin) } before do - allow(ApplicationSetting).to receive(:current_without_cache) { application_setting } - application_setting.allow_local_requests_from_web_hooks_and_services = true + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + + application_setting.update(allow_local_requests_from_web_hooks_and_services: true) end shared_examples 'has prometheus service' do |listen_address| @@ -130,12 +131,17 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do it 'saves the project id' do expect(result[:status]).to eq(:success) - expect(application_setting.self_monitoring_project_id).to eq(project.id) + expect(application_setting.reload.self_monitoring_project_id).to eq(project.id) end - it 'expires application_setting cache' do - expect(Gitlab::CurrentSettings).to receive(:expire_current_application_settings) + it 'creates a Prometheus service' do expect(result[:status]).to eq(:success) + + services = result[:project].reload.services + + expect(services.count).to eq(1) + # Ensures PrometheusService#self_monitoring_project? is true + expect(services.first.allow_local_api_url?).to be_truthy end it 'creates an environment for the project' do @@ -158,8 +164,8 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do end it 'returns error when saving project ID fails' do - allow(application_setting).to receive(:update).and_call_original - allow(application_setting).to receive(:update) + allow(subject.application_settings).to receive(:update).and_call_original + allow(subject.application_settings).to receive(:update) .with(self_monitoring_project_id: anything) .and_return(false) @@ -175,8 +181,8 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do let(:existing_project) { create(:project, namespace: existing_group) } before do - application_setting.instance_administrators_group_id = existing_group.id - application_setting.self_monitoring_project_id = existing_project.id + application_setting.update(instance_administrators_group_id: existing_group.id, + self_monitoring_project_id: existing_project.id) end it 'returns success' do @@ -189,7 +195,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do context 'when local requests from hooks and services are not allowed' do before do - application_setting.allow_local_requests_from_web_hooks_and_services = false + application_setting.update(allow_local_requests_from_web_hooks_and_services: false) end it_behaves_like 'has prometheus service', 'http://localhost:9090' diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index 563e0590482..45701b501bb 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -274,7 +274,6 @@ describe Gitlab::GitalyClient::OperationService do end describe '#user_squash' do - let(:branch_name) { 'my-branch' } let(:squash_id) { '1' } let(:start_sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' } let(:end_sha) { '54cec5282aa9f21856362fe321c800c236a61615' } @@ -284,7 +283,6 @@ describe Gitlab::GitalyClient::OperationService do repository: repository.gitaly_repository, user: gitaly_user, squash_id: squash_id.to_s, - branch: branch_name, start_sha: start_sha, end_sha: end_sha, author: gitaly_user, @@ -295,7 +293,7 @@ describe Gitlab::GitalyClient::OperationService do let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) } subject do - client.user_squash(user, squash_id, branch_name, start_sha, end_sha, user, commit_message) + client.user_squash(user, squash_id, start_sha, end_sha, user, commit_message) end it 'sends a user_squash message and returns the squash sha' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2c6cfce7247..ae97e5340e2 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1401,6 +1401,22 @@ describe Project do expect(project.repository_storage).to eq('picked') end + + it 'picks from the latest available storage', :request_store do + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + Gitlab::CurrentSettings.current_application_settings + + settings = ApplicationSetting.last + settings.repository_storages = %w(picked) + settings.save! + + expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(default)) + + project + + expect(project.repository.storage).to eq('picked') + expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(picked)) + end end context 'shared runners by default' do