diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-16 03:10:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-16 03:10:02 +0300 |
commit | 5074a6923ee1572d5e0590191206e0e4a4849287 (patch) | |
tree | 1e133860198749a655cb255fe407838181988449 | |
parent | a2fd863d3be23fee66ec7036b8febb2605c17767 (diff) |
Add latest changes from gitlab-org/gitlab@master
27 files changed, 174 insertions, 55 deletions
diff --git a/.rubocop_todo/style/symbol_proc.yml b/.rubocop_todo/style/symbol_proc.yml index 770b99109b4..75aab7c6116 100644 --- a/.rubocop_todo/style/symbol_proc.yml +++ b/.rubocop_todo/style/symbol_proc.yml @@ -92,6 +92,7 @@ Style/SymbolProc: - 'db/migrate/20210318134427_delete_security_findings_without_uuid.rb' - 'db/migrate/20210503105845_add_project_value_stream_id_to_project_stages.rb' - 'db/post_migrate/20220119094503_populate_audit_event_streaming_verification_token.rb' + - 'db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb' - 'ee/app/helpers/ee/mirror_helper.rb' - 'ee/app/helpers/ee/registrations_helper.rb' - 'ee/app/models/concerns/epic_tree_sorting.rb' diff --git a/Gemfile.lock b/Gemfile.lock index 5359aabb30b..f04445e1d57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -578,8 +578,8 @@ GEM retriable (>= 2.0, < 4.0) rexml signet (~> 0.12) - google-cloud-env (1.5.0) - faraday (>= 0.17.3, < 2.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) google-protobuf (3.21.3) googleapis-common-protos-types (1.3.0) google-protobuf (~> 3.14) diff --git a/app/controllers/projects/google_cloud/base_controller.rb b/app/controllers/projects/google_cloud/base_controller.rb index 050b26a40c7..d1eb86c5e49 100644 --- a/app/controllers/projects/google_cloud/base_controller.rb +++ b/app/controllers/projects/google_cloud/base_controller.rb @@ -80,4 +80,16 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController Gitlab::Tracking.event('Projects::GoogleCloud', action, **options) end + + def gcp_projects + google_api_client = GoogleApi::CloudPlatform::Client.new(token_in_session, nil) + google_api_client.list_projects + end + + def refs + params = { per_page: 50 } + branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true) + tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true) + (branches + tags).map(&:name) + end end diff --git a/app/controllers/projects/google_cloud/configuration_controller.rb b/app/controllers/projects/google_cloud/configuration_controller.rb index fa672058247..8d252c35031 100644 --- a/app/controllers/projects/google_cloud/configuration_controller.rb +++ b/app/controllers/projects/google_cloud/configuration_controller.rb @@ -4,7 +4,6 @@ module Projects module GoogleCloud class ConfigurationController < Projects::GoogleCloud::BaseController def index - @google_cloud_path = project_google_cloud_configuration_path(project) js_data = { configurationUrl: project_google_cloud_configuration_path(project), deploymentsUrl: project_google_cloud_deployments_path(project), diff --git a/app/controllers/projects/google_cloud/databases_controller.rb b/app/controllers/projects/google_cloud/databases_controller.rb index 711409e7550..7b1cf6e5ce1 100644 --- a/app/controllers/projects/google_cloud/databases_controller.rb +++ b/app/controllers/projects/google_cloud/databases_controller.rb @@ -4,7 +4,6 @@ module Projects module GoogleCloud class DatabasesController < Projects::GoogleCloud::BaseController def index - @google_cloud_path = project_google_cloud_configuration_path(project) js_data = { configurationUrl: project_google_cloud_configuration_path(project), deploymentsUrl: project_google_cloud_deployments_path(project), diff --git a/app/controllers/projects/google_cloud/deployments_controller.rb b/app/controllers/projects/google_cloud/deployments_controller.rb index e8b100eb2ed..1ac4697a63f 100644 --- a/app/controllers/projects/google_cloud/deployments_controller.rb +++ b/app/controllers/projects/google_cloud/deployments_controller.rb @@ -4,7 +4,6 @@ class Projects::GoogleCloud::DeploymentsController < Projects::GoogleCloud::Base before_action :validate_gcp_token! def index - @google_cloud_path = project_google_cloud_configuration_path(project) js_data = { configurationUrl: project_google_cloud_configuration_path(project), deploymentsUrl: project_google_cloud_deployments_path(project), diff --git a/app/controllers/projects/google_cloud/gcp_regions_controller.rb b/app/controllers/projects/google_cloud/gcp_regions_controller.rb index c526db9ff3e..39f33624804 100644 --- a/app/controllers/projects/google_cloud/gcp_regions_controller.rb +++ b/app/controllers/projects/google_cloud/gcp_regions_controller.rb @@ -9,11 +9,6 @@ class Projects::GoogleCloud::GcpRegionsController < Projects::GoogleCloud::BaseC GCP_REGION_CI_VAR_KEY = 'GCP_REGION' def index - @google_cloud_path = project_google_cloud_configuration_path(project) - params = { per_page: 50 } - branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true) - tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true) - refs = (branches + tags).map(&:name) js_data = { availableRegions: AVAILABLE_REGIONS, refs: refs, diff --git a/app/controllers/projects/google_cloud/service_accounts_controller.rb b/app/controllers/projects/google_cloud/service_accounts_controller.rb index 29dc9f05178..7f25054177e 100644 --- a/app/controllers/projects/google_cloud/service_accounts_controller.rb +++ b/app/controllers/projects/google_cloud/service_accounts_controller.rb @@ -4,19 +4,11 @@ class Projects::GoogleCloud::ServiceAccountsController < Projects::GoogleCloud:: before_action :validate_gcp_token! def index - @google_cloud_path = project_google_cloud_configuration_path(project) - google_api_client = GoogleApi::CloudPlatform::Client.new(token_in_session, nil) - gcp_projects = google_api_client.list_projects - if gcp_projects.empty? track_event('service_accounts#index', 'error_form', 'no_gcp_projects') flash[:warning] = _('No Google Cloud projects - You need at least one Google Cloud project') redirect_to project_google_cloud_configuration_path(project) else - params = { per_page: 50 } - branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true) - tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true) - refs = (branches + tags).map(&:name) js_data = { gcpProjects: gcp_projects, refs: refs, diff --git a/app/helpers/admin/identities_helper.rb b/app/helpers/admin/identities_helper.rb index 8557f322bff..48e01840394 100644 --- a/app/helpers/admin/identities_helper.rb +++ b/app/helpers/admin/identities_helper.rb @@ -22,6 +22,14 @@ module Admin def saml_group_link(identity) '-' end + + def identity_cells_to_render?(identities, _user) + identities.present? + end + + def scim_identities_collection(_user) + [] + end end end diff --git a/app/views/admin/identities/index.html.haml b/app/views/admin/identities/index.html.haml index 99d5e2a93c4..1bb14969939 100644 --- a/app/views/admin/identities/index.html.haml +++ b/app/views/admin/identities/index.html.haml @@ -11,8 +11,10 @@ %th{ class: 'gl-border-t-0!' }= _('Group') %th{ class: 'gl-border-t-0!' }= _('Identifier') %th{ class: 'gl-border-t-0!' }= _('Actions') - = render @identities - - if @identities.blank? + - if identity_cells_to_render?(@identities, @user) + = render_if_exists partial: 'admin/identities/scim_identity', collection: scim_identities_collection(@user) + = render @identities + - else %tbody %tr %td{ colspan: '5' } diff --git a/app/views/projects/google_cloud/configuration/index.html.haml b/app/views/projects/google_cloud/configuration/index.html.haml index ec977898f47..dab49d5032a 100644 --- a/app/views/projects/google_cloud/configuration/index.html.haml +++ b/app/views/projects/google_cloud/configuration/index.html.haml @@ -1,4 +1,4 @@ -- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path +- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project) - breadcrumb_title s_('CloudSeed|Configuration') - page_title s_('CloudSeed|Configuration') diff --git a/app/views/projects/google_cloud/databases/index.html.haml b/app/views/projects/google_cloud/databases/index.html.haml index ad732317d8d..0528ac3d1f5 100644 --- a/app/views/projects/google_cloud/databases/index.html.haml +++ b/app/views/projects/google_cloud/databases/index.html.haml @@ -1,4 +1,4 @@ -- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path +- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project) - breadcrumb_title s_('CloudSeed|Databases') - page_title s_('CloudSeed|Databases') diff --git a/app/views/projects/google_cloud/deployments/index.html.haml b/app/views/projects/google_cloud/deployments/index.html.haml index b140159a7f5..22a365671bc 100644 --- a/app/views/projects/google_cloud/deployments/index.html.haml +++ b/app/views/projects/google_cloud/deployments/index.html.haml @@ -1,4 +1,4 @@ -- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path +- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project) - breadcrumb_title s_('CloudSeed|Deployments') - page_title s_('CloudSeed|Deployments') diff --git a/app/views/projects/google_cloud/gcp_regions/index.html.haml b/app/views/projects/google_cloud/gcp_regions/index.html.haml index d7cabaa029b..36b5630611e 100644 --- a/app/views/projects/google_cloud/gcp_regions/index.html.haml +++ b/app/views/projects/google_cloud/gcp_regions/index.html.haml @@ -1,4 +1,4 @@ -- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path +- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project) - breadcrumb_title _('CloudSeed|Regions') - page_title s_('CloudSeed|Regions') diff --git a/app/views/projects/google_cloud/service_accounts/index.html.haml b/app/views/projects/google_cloud/service_accounts/index.html.haml index 6191de577fe..8f70818abd9 100644 --- a/app/views/projects/google_cloud/service_accounts/index.html.haml +++ b/app/views/projects/google_cloud/service_accounts/index.html.haml @@ -1,4 +1,4 @@ -- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path +- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project) - breadcrumb_title s_('CloudSeed|Service Account') - page_title s_('CloudSeed|Service Account') diff --git a/config/routes/project.rb b/config/routes/project.rb index d22029b6055..63e960a9b4c 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -298,6 +298,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resources :terraform, only: [:index] namespace :google_cloud do + get '/', to: redirect('%{namespace_id}/%{project_id}/-/google_cloud/configuration') + get '/configuration', to: 'configuration#index' resources :revoke_oauth, only: [:create] diff --git a/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb b/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb new file mode 100644 index 00000000000..fa80b2b95e7 --- /dev/null +++ b/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddTmpIndexTodosAttentionRequestAction < Gitlab::Database::Migration[2.0] + INDEX_NAME = "tmp_index_todos_attention_request_action" + ATTENTION_REQUESTED = 10 + + disable_ddl_transaction! + + def up + add_concurrent_index :todos, [:id], + where: "action = #{ATTENTION_REQUESTED}", + name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :todos, INDEX_NAME + end +end diff --git a/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb b/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb new file mode 100644 index 00000000000..d3b281b08ad --- /dev/null +++ b/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class CleanupMrAttentionRequestTodos < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + class Todo < MigrationRecord + self.table_name = 'todos' + + include ::EachBatch + + ATTENTION_REQUESTED = 10 + end + + def up + Todo.where(action: Todo::ATTENTION_REQUESTED).each_batch do |todos_batch| + todos_batch.delete_all + end + end + + def down + # Attention request feature has been reverted. + end +end diff --git a/db/schema_migrations/20220803042351 b/db/schema_migrations/20220803042351 new file mode 100644 index 00000000000..1b35b709eaf --- /dev/null +++ b/db/schema_migrations/20220803042351 @@ -0,0 +1 @@ +50c58b03d92451753cbdcb2e820e7d1ca9644f914027db46b57d2206e7832ec7
\ No newline at end of file diff --git a/db/schema_migrations/20220803042352 b/db/schema_migrations/20220803042352 new file mode 100644 index 00000000000..011051cd5e4 --- /dev/null +++ b/db/schema_migrations/20220803042352 @@ -0,0 +1 @@ +03d95257a9169a33a90baf28a6737f68fb999f920450a1cb90732820490be1c4
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index dc5f55a86b0..19f635127b6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -30514,6 +30514,8 @@ CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statistics USING btree (project_id) WHERE (container_registry_size = 0); +CREATE INDEX tmp_index_todos_attention_request_action ON todos USING btree (id) WHERE (action = 10); + CREATE INDEX tmp_index_vulnerability_occurrences_on_id_and_scanner_id ON vulnerability_occurrences USING btree (id, scanner_id) WHERE (report_type = ANY (ARRAY[7, 99])); CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name); diff --git a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md index 853cc195982..b452d7c0564 100644 --- a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md +++ b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md @@ -423,23 +423,6 @@ projects = Project.find_by_sql("SELECT * FROM projects WHERE name LIKE '%ject'") => [#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>] ``` -## Wikis - -### Recreate - -WARNING: -This is a destructive operation, the Wiki becomes empty. - -A Projects Wiki can be recreated by this command: - -```ruby -p = Project.find_by_full_path('<username-or-group>/<project-name>') ### enter your projects path - -GitlabShellWorker.perform_in(0, :remove_repository, p.repository_storage, p.wiki.disk_path) ### deletes the wiki project from the filesystem - -p.create_wiki ### creates the wiki project on the filesystem -``` - ## Issue boards ### In case of issue boards not loading properly and it's getting time out. Call the Issue Rebalancing service to fix this diff --git a/doc/user/project/wiki/index.md b/doc/user/project/wiki/index.md index f3faa66a175..c7f675417bb 100644 --- a/doc/user/project/wiki/index.md +++ b/doc/user/project/wiki/index.md @@ -382,3 +382,26 @@ In GitLab 14.9 and later, page slugs are now encoded using the [`ERB::Util.url_encode`](https://www.rubydoc.info/stdlib/erb/ERB%2FUtil.url_encode) method. If you use an Apache reverse proxy, you can add a `nocanon` argument to the `ProxyPass` line of your Apache configuration to ensure your page slugs render correctly. + +### Recreate a project wiki with the Rails console **(FREE SELF)** + +WARNING: +This operation deletes all data in the wiki. + +To clear all data from a project wiki and recreate it in a blank state: + +1. [Start a Rails console session](../../../administration/operations/rails_console.md#starting-a-rails-console-session). +1. Run these commands: + + ```ruby + # Enter your project's path + p = Project.find_by_full_path('<username-or-group>/<project-name>') + + # This command deletes the wiki project from the filesystem. + GitlabShellWorker.perform_in(0, :remove_repository, p.repository_storage, p.wiki.disk_path) + + # Refresh the wiki repository state. + p.wiki.repository.expire_exists_cache + ``` + +All data from the wiki has been cleared, and the wiki is ready for use. diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index fb1b6657012..39cf994ca3f 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -166,10 +166,7 @@ module GoogleApi end def list_cloudsql_databases(gcp_project_id, instance_name) - service = Google::Apis::SqladminV1beta4::SQLAdminService.new - service.authorization = access_token - - service.list_databases(gcp_project_id, instance_name, options: user_agent_header) + sql_admin_service.list_databases(gcp_project_id, instance_name, options: user_agent_header) end def create_cloudsql_database(gcp_project_id, instance_name, database_name) @@ -178,10 +175,7 @@ module GoogleApi end def list_cloudsql_users(gcp_project_id, instance_name) - service = Google::Apis::SqladminV1beta4::SQLAdminService.new - service.authorization = access_token - - service.list_users(gcp_project_id, instance_name, options: user_agent_header) + sql_admin_service.list_users(gcp_project_id, instance_name, options: user_agent_header) end def create_cloudsql_user(gcp_project_id, instance_name, username, password) @@ -204,9 +198,7 @@ module GoogleApi settings: Google::Apis::SqladminV1beta4::Settings.new(tier: tier) ) - service = Google::Apis::SqladminV1beta4::SQLAdminService.new - service.authorization = access_token - service.insert_instance(gcp_project_id, database_instance) + sql_admin_service.insert_instance(gcp_project_id, database_instance) end private diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index c36b208d895..434219d3cde 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -148,8 +148,8 @@ GEM google-apis-core (>= 0.4, < 2.a) google-apis-storage_v1 (0.9.0) google-apis-core (>= 0.4, < 2.a) - google-cloud-env (1.5.0) - faraday (>= 0.17.3, < 2.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) googleauth (1.1.0) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) diff --git a/spec/helpers/admin/identities_helper_spec.rb b/spec/helpers/admin/identities_helper_spec.rb index f8e56e4f32d..9a7fdd3aa69 100644 --- a/spec/helpers/admin/identities_helper_spec.rb +++ b/spec/helpers/admin/identities_helper_spec.rb @@ -35,4 +35,24 @@ RSpec.describe Admin::IdentitiesHelper do expect(helper.saml_group_link(identity)).to eq '-' end end + + describe '#identity_cells_to_render?' do + context 'without identities' do + it 'returns false' do + expect(helper.identity_cells_to_render?([], user)).to eq false + end + end + + context 'with identities' do + it 'returns true' do + expect(helper.identity_cells_to_render?(identity, user)).to eq true + end + end + end + + describe '#scim_identities_collection' do + it 'returns empty array' do + expect(helper.scim_identities_collection(user)).to eq [] + end + end end diff --git a/spec/migrations/cleanup_mr_attention_request_todos_spec.rb b/spec/migrations/cleanup_mr_attention_request_todos_spec.rb new file mode 100644 index 00000000000..9f593ca8292 --- /dev/null +++ b/spec/migrations/cleanup_mr_attention_request_todos_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe CleanupMrAttentionRequestTodos, :migration do + let(:projects) { table(:projects) } + let(:namespaces) { table(:namespaces) } + let(:users) { table(:users) } + let(:todos) { table(:todos) } + + let(:author) { users.create!(projects_limit: 1) } + let(:namespace) { namespaces.create!(name: 'test', path: 'test') } + let(:project) do + projects.create!( + namespace_id: namespace.id, + project_namespace_id: namespace.id, + name: 'test-project' + ) + end + + let(:attention_requested) { 10 } + let(:todo_attrs) do + { + project_id: project.id, + author_id: author.id, + user_id: author.id, + target_type: 'TestType', + state: 'pending' + } + end + + let!(:todo1) { todos.create!(todo_attrs.merge(action: Todo::ASSIGNED)) } + let!(:todo2) { todos.create!(todo_attrs.merge(action: Todo::MENTIONED)) } + let!(:todo3) { todos.create!(todo_attrs.merge(action: Todo::REVIEW_REQUESTED)) } + let!(:todo4) { todos.create!(todo_attrs.merge(action: attention_requested)) } + let!(:todo5) { todos.create!(todo_attrs.merge(action: attention_requested)) } + + describe '#up' do + it 'clean up attention request todos' do + expect { migrate! }.to change(todos, :count).by(-2) + + expect(todos.all).to include(todo1, todo2, todo3) + end + end +end |