From 4148df7b7365f1817aa657c9ffc7e3bc96bd738a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 11 Dec 2023 00:07:38 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/controllers/admin/clusters_controller.rb | 2 +- app/controllers/clusters/base_controller.rb | 6 ++ app/controllers/clusters/clusters_controller.rb | 2 +- app/controllers/groups/clusters_controller.rb | 5 +- app/controllers/projects/clusters_controller.rb | 5 +- db/docs/users.yml | 3 + ...2752_add_options_to_elastic_reindexing_tasks.rb | 9 ++ ...invalid_protected_branch_merge_access_levels.rb | 1 - ..._invalid_protected_branch_push_access_levels.rb | 1 - ...e_invalid_protected_tag_create_access_levels.rb | 1 - ...1209_queue_backfill_packages_tags_project_id.rb | 1 - ...ueue_backfill_merge_request_diffs_project_id.rb | 1 - ...fill_has_remediations_of_vulnerability_reads.rb | 1 - ...049_drop_index_users_on_id_and_last_activity.rb | 28 ++++++ db/schema_migrations/20231130192752 | 1 + db/schema_migrations/20231208103049 | 1 + db/structure.sql | 1 + .../database/batched_background_migrations.md | 65 ++++++------- doc/development/database/not_null_constraints.md | 3 +- doc/integration/jira/troubleshooting.md | 27 ++++++ doc/user/project/merge_requests/conflicts.md | 101 +++++++++++---------- .../merge_requests/img/conflict_section.png | Bin 72815 -> 0 bytes .../merge_requests/img/conflict_section_v16_7.png | Bin 0 -> 32753 bytes .../project/merge_requests/img/conflicts_v16_7.png | Bin 0 -> 10637 bytes .../merge_requests/img/merge_conflict_editor.png | Bin 50286 -> 0 bytes .../img/merge_conflict_editor_v16_7.png | Bin 0 -> 13729 bytes .../merge_requests/img/merge_request_widget.png | Bin 8936 -> 0 bytes .../queue_batched_background_migration.template | 1 - .../batched_background_migration_helpers.rb | 11 +-- spec/features/groups/clusters/user_spec.rb | 19 ++++ spec/features/projects/clusters/user_spec.rb | 19 ++++ .../expected_files/queue_my_batched_migration.txt | 1 - .../batched_background_migration_helpers_spec.rb | 6 +- 33 files changed, 209 insertions(+), 113 deletions(-) create mode 100644 db/migrate/20231130192752_add_options_to_elastic_reindexing_tasks.rb create mode 100644 db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb create mode 100644 db/schema_migrations/20231130192752 create mode 100644 db/schema_migrations/20231208103049 delete mode 100644 doc/user/project/merge_requests/img/conflict_section.png create mode 100644 doc/user/project/merge_requests/img/conflict_section_v16_7.png create mode 100644 doc/user/project/merge_requests/img/conflicts_v16_7.png delete mode 100644 doc/user/project/merge_requests/img/merge_conflict_editor.png create mode 100644 doc/user/project/merge_requests/img/merge_conflict_editor_v16_7.png delete mode 100644 doc/user/project/merge_requests/img/merge_request_widget.png diff --git a/app/controllers/admin/clusters_controller.rb b/app/controllers/admin/clusters_controller.rb index 052c8821588..ead02a7aa8c 100644 --- a/app/controllers/admin/clusters_controller.rb +++ b/app/controllers/admin/clusters_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Admin::ClustersController < Clusters::ClustersController +class Admin::ClustersController < ::Clusters::ClustersController include EnforcesAdminAuthentication before_action :ensure_feature_enabled! diff --git a/app/controllers/clusters/base_controller.rb b/app/controllers/clusters/base_controller.rb index e7b76b87ad9..495b6463383 100644 --- a/app/controllers/clusters/base_controller.rb +++ b/app/controllers/clusters/base_controller.rb @@ -4,6 +4,7 @@ class Clusters::BaseController < ApplicationController include RoutableActions skip_before_action :authenticate_user! + before_action :clusterable before_action :authorize_admin_cluster!, except: [:show, :index, :new, :authorize_aws_role, :update] helper_method :clusterable @@ -41,6 +42,11 @@ class Clusters::BaseController < ApplicationController access_denied! unless can?(current_user, :read_prometheus, clusterable) end + # For Group/Clusters and Project/Clusters, the clusterable object (group or project) + # is fetched through `find_routable!`, which calls a `render_404` if the user does not have access to the object + # The `clusterable` method will need to be in its own before_action call before the `authorize_*` calls + # so that the call stack will not proceed to the `authorize_*` calls + # and instead just render a not found page after the `clusterable` call def clusterable raise NotImplementedError end diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb index b012a4e003e..917007144fa 100644 --- a/app/controllers/clusters/clusters_controller.rb +++ b/app/controllers/clusters/clusters_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Clusters::ClustersController < Clusters::BaseController +class Clusters::ClustersController < ::Clusters::BaseController include RoutableActions before_action :cluster, only: [:cluster_status, :show, :update, :destroy, :clear_cache] diff --git a/app/controllers/groups/clusters_controller.rb b/app/controllers/groups/clusters_controller.rb index 2fe9faa252f..5b1508f44a2 100644 --- a/app/controllers/groups/clusters_controller.rb +++ b/app/controllers/groups/clusters_controller.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true -class Groups::ClustersController < Clusters::ClustersController +class Groups::ClustersController < ::Clusters::ClustersController include ControllerWithCrossProjectAccessCheck before_action :ensure_feature_enabled! - prepend_before_action :group requires_cross_project_access layout 'group' @@ -12,7 +11,7 @@ class Groups::ClustersController < Clusters::ClustersController private def clusterable - @clusterable ||= ClusterablePresenter.fabricate(group, current_user: current_user) + @clusterable ||= group && ClusterablePresenter.fabricate(group, current_user: current_user) end def group diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index b781365b3c3..dd969efa49b 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true -class Projects::ClustersController < Clusters::ClustersController - prepend_before_action :project +class Projects::ClustersController < ::Clusters::ClustersController before_action :repository before_action do @@ -13,7 +12,7 @@ class Projects::ClustersController < Clusters::ClustersController private def clusterable - @clusterable ||= ClusterablePresenter.fabricate(project, current_user: current_user) + @clusterable ||= project && ClusterablePresenter.fabricate(project, current_user: current_user) end def project diff --git a/db/docs/users.yml b/db/docs/users.yml index 43bec30b9dd..f2c305ccc8d 100644 --- a/db/docs/users.yml +++ b/db/docs/users.yml @@ -13,3 +13,6 @@ schema_inconsistencies: - type: missing_indexes object_name: index_users_for_auditors introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138110 +- type: missing_indexes + object_name: index_users_on_id_and_last_activity_on_for_active_human_service + introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139230 diff --git a/db/migrate/20231130192752_add_options_to_elastic_reindexing_tasks.rb b/db/migrate/20231130192752_add_options_to_elastic_reindexing_tasks.rb new file mode 100644 index 00000000000..3a94e6d600b --- /dev/null +++ b/db/migrate/20231130192752_add_options_to_elastic_reindexing_tasks.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddOptionsToElasticReindexingTasks < Gitlab::Database::Migration[2.2] + milestone '16.7' + + def change + add_column :elastic_reindexing_tasks, :options, :jsonb, null: false, default: {} + end +end diff --git a/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb index 3f4009d783c..8d6173fc7ca 100644 --- a/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb +++ b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb @@ -16,7 +16,6 @@ class QueueDeleteInvalidProtectedBranchMergeAccessLevels < Gitlab::Database::Mig :protected_branch_merge_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016173129', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb index 6accaa3296b..32022ff8be0 100644 --- a/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb +++ b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb @@ -16,7 +16,6 @@ class QueueDeleteInvalidProtectedBranchPushAccessLevels < Gitlab::Database::Migr :protected_branch_push_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016194927', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb index 5880124d0a6..f96f1c3b380 100644 --- a/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb +++ b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb @@ -15,7 +15,6 @@ class QueueDeleteInvalidProtectedTagCreateAccessLevels < Gitlab::Database::Migra :protected_tag_create_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016194943', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb b/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb index 4984eb83263..1197e31dea8 100644 --- a/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb +++ b/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb @@ -16,7 +16,6 @@ class QueueBackfillPackagesTagsProjectId < Gitlab::Database::Migration[2.2] :packages_tags, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231030071209', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb b/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb index 0dc15f5c56f..19448243fdc 100644 --- a/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb +++ b/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb @@ -15,7 +15,6 @@ class QueueBackfillMergeRequestDiffsProjectId < Gitlab::Database::Migration[2.2] :merge_request_diffs, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231114043522', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb b/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb index e49a49d7912..35b6de08f10 100644 --- a/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb +++ b/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb @@ -22,7 +22,6 @@ class Requeue2BackfillHasRemediationsOfVulnerabilityReads < Gitlab::Database::Mi :vulnerability_reads, :vulnerability_id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231201204712', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb b/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb new file mode 100644 index 00000000000..bf9b1800c68 --- /dev/null +++ b/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class DropIndexUsersOnIdAndLastActivity < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_on_id_and_last_activity_on_for_active_human_service + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index :users, [:id, :last_activity_on], + name: INDEX_NAME, + where: "state = 'active' AND user_type IN (0, 4)" + end + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/schema_migrations/20231130192752 b/db/schema_migrations/20231130192752 new file mode 100644 index 00000000000..f5bbda5c8a1 --- /dev/null +++ b/db/schema_migrations/20231130192752 @@ -0,0 +1 @@ +4777e51867476bd6c7b2a259866cf3453ef784f409ace94efd799de959288748 \ No newline at end of file diff --git a/db/schema_migrations/20231208103049 b/db/schema_migrations/20231208103049 new file mode 100644 index 00000000000..f478c39466a --- /dev/null +++ b/db/schema_migrations/20231208103049 @@ -0,0 +1 @@ +a4c1bb4cdab6a0e9723849ec7dadf9fc8286cbd05c0b160c513fdbf727f6e0b6 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index cb9877ecb67..4f1aef9a8d0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -16345,6 +16345,7 @@ CREATE TABLE elastic_reindexing_tasks ( max_slices_running smallint DEFAULT 60 NOT NULL, slice_multiplier smallint DEFAULT 2 NOT NULL, targets text[], + options jsonb DEFAULT '{}'::jsonb NOT NULL, CONSTRAINT check_7f64acda8e CHECK ((char_length(error_message) <= 255)) ); diff --git a/doc/development/database/batched_background_migrations.md b/doc/development/database/batched_background_migrations.md index 4605447f256..03f5eedb7f8 100644 --- a/doc/development/database/batched_background_migrations.md +++ b/doc/development/database/batched_background_migrations.md @@ -672,49 +672,37 @@ The following process has been configured to make dependencies more evident whil Example: ```ruby - class QueueBackfillRoutesNamespaceId < Gitlab::Database::Migration[2.1] - MIGRATION = 'BackfillRouteNamespaceId' -.... - restrict_gitlab_migration gitlab_schema: :gitlab_main +# db/post_migrate/20231113120650_queue_backfill_routes_namespace_id.rb +class QueueBackfillRoutesNamespaceId < Gitlab::Database::Migration[2.1] + MIGRATION = 'BackfillRouteNamespaceId' - def up - queue_batched_background_migration( - ... - queued_migration_version: '20231113120650', - ... - ) - end -... - end - ``` + restrict_gitlab_migration gitlab_schema: :gitlab_main + ... + ... - ```ruby - class NewQueueBackfillRoutesNamespaceId < Gitlab::Database::Migration[2.1] - MIGRATION = 'NewBackfillRouteNamespaceId' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 100 - DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = ["20231113120650"] + def up + queue_batched_background_migration( + MIGRATION, + ... + ) + end +end +``` - restrict_gitlab_migration gitlab_schema: :gitlab_main +```ruby +# This depends on the finalization of QueueBackfillRoutesNamespaceId BBM +class AddNotNullToRoutesNamespaceId < Gitlab::Database::Migration[2.1] + DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = ["20231113120650"] - def up - queue_batched_background_migration( - MIGRATION, - :routes, - :id, - job_interval: DELAY_INTERVAL, - queued_migration_version: '20241213120651', - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + def up + add_not_null_constraint :routes, :namespace_id + end - def down - delete_batched_background_migration(MIGRATION, :routes, :id, []) - end - end - ``` + def down + remove_not_null_constraint :routes, :namespace_id + end +end +``` #### Notes @@ -1062,7 +1050,6 @@ background migration. :routes, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231113120650', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/doc/development/database/not_null_constraints.md b/doc/development/database/not_null_constraints.md index 7ffc1fba1a0..5615edfcc2a 100644 --- a/doc/development/database/not_null_constraints.md +++ b/doc/development/database/not_null_constraints.md @@ -242,8 +242,7 @@ scheduled after the background migration has completed, which could be several r MIGRATION, :merge_request_diffs, :id, - job_interval: DELAY_INTERVAL, - queued_migration_version: '20231114043522' + job_interval: DELAY_INTERVAL ) end diff --git a/doc/integration/jira/troubleshooting.md b/doc/integration/jira/troubleshooting.md index 42cdb72b9f1..ab9a750605d 100644 --- a/doc/integration/jira/troubleshooting.md +++ b/doc/integration/jira/troubleshooting.md @@ -80,6 +80,33 @@ There is a [known bug](https://gitlab.com/gitlab-org/gitlab/-/issues/341571) where the Jira integration sometimes does not work for a project that has been imported. As a workaround, disable the integration and then re-enable it. +### `certificate verify failed` when testing or using the Jira issue integration + +When testing the Jira integration settings, you might see the following error: + +```plaintext +Connection failed. Check your integration settings. SSL_connect returned=1 errno=0 peeraddr= state=error: certificate verify failed (unable to get local issuer certificate) +``` + +This error might also appear in the [`integrations_json.log`](../../administration/logs/index.md#integrations_jsonlog) file: + +```json +{ + "severity":"ERROR", + "integration_class":"Integrations::Jira", + "message":"Error sending message", + "exception.class":"OpenSSL::SSL::SSLError", + "exception.message":"SSL_connect returned=1 errno=0 peeraddr=x.x.x.x:443 state=error: certificate verify failed (unable to get local issuer certificate)", +} +``` + +The error occurs because the Jira certificate isn't publicly trusted, or the certificate chain is incomplete. Until this is resolved, GitLab won't connect to Jira. + +There can be other variations of this error message that are listed on the [common SSL errors](https://docs.gitlab.com/omnibus/settings/ssl/ssl_troubleshooting.html#common-ssl-errors) page. + +To resolve this, refer to the +[common SSL errors](https://docs.gitlab.com/omnibus/settings/ssl/ssl_troubleshooting.html#common-ssl-errors) page. + ### Change all Jira projects to instance-level or group-level values WARNING: diff --git a/doc/user/project/merge_requests/conflicts.md b/doc/user/project/merge_requests/conflicts.md index d61753c3b40..f3fd38bdcef 100644 --- a/doc/user/project/merge_requests/conflicts.md +++ b/doc/user/project/merge_requests/conflicts.md @@ -6,18 +6,39 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Merge conflicts **(FREE ALL)** -_Merge conflicts_ happen when the two branches in a merge request (the source and target) each have different +Merge conflicts happen when the two branches in a merge request (the source and target) each have different changes, and you must decide which change to accept. In a merge request, Git compares the two versions of the files line by line. In most cases, GitLab can merge changes together. However, if two branches both change the same lines, GitLab blocks the merge, -and you must choose which change you want to keep. +and you must choose which change you want to keep: -A merge request cannot merge until you either: +![A merge request blocked due to a merge conflict](img/conflicts_v16_7.png) + +A merge request with conflicts cannot merge until you either: - Create a merge commit. - Resolve the conflict through a rebase. -![Merge request widget](img/merge_request_widget.png) +GitLab resolves conflicts by creating a merge commit in the source branch, but +does not merge it into the target branch. You can then review and test the +merge commit. Verify it contains no unintended changes and doesn't break your build. + +## Understand the conflict block + +When Git detects a conflict that requires a decision on your part, it marks the +beginning and end of the conflict block with conflict markers: + +- `<<<<<<< HEAD` marks the beginning of the conflict block. +- Your changes are shown. +- `=======` marks the end of your changes. +- The latest changes in the target branch are shown. +- `>>>>>>>` marks the end of the conflict. + +When you resolve a conflict, you delete: + +1. The version of the conflicted lines you don't want to keep. +1. The three conflict markers: the beginning, the end, and the `=======` line between + the two versions. ## Conflicts you can resolve in the user interface @@ -38,23 +59,23 @@ criteria, you must resolve the conflict manually. GitLab does not detect conflicts when both branches rename a file to different names. For example, these changes don't create a conflict: -1. On branch `a`, doing `git mv example.txt example1.txt` -1. On branch `b`, doing `git mv example1.txt example3.txt`. +1. Branch `one` renames `example.txt` to `example1.txt` +1. Branch `two` renames `example.txt` to `example_old.txt`. -When these branches merge, both `example1.txt` and `example3.txt` are present. +When these branches merge, both `example1.txt` and `example_old` are present. ## Methods of resolving conflicts GitLab shows [conflicts available for resolution](#conflicts-you-can-resolve-in-the-user-interface) in the user interface, and you can also resolve conflicts locally through the command line: -- [Interactive mode](#resolve-conflicts-in-interactive-mode): UI method best for +- **Interactive mode**: UI method best for conflicts that only require you to select which version of a line to keep, without edits. -- [Inline editor](#resolve-conflicts-in-the-inline-editor): UI method best for more complex conflicts that require you to +- **Inline editor**: UI method best for more complex conflicts that require you to edit lines and manually blend changes together. -- [Command line](#resolve-conflicts-from-the-command-line): provides complete control over the most complex conflicts. +- **Command line**: provides complete control over the most complex conflicts. -## Resolve conflicts in interactive mode +### In interactive mode To resolve less-complex conflicts from the GitLab user interface: @@ -62,14 +83,15 @@ To resolve less-complex conflicts from the GitLab user interface: 1. Select **Code > Merge requests** and find the merge request. 1. Select **Overview**, and scroll to the merge request reports section. 1. Find the merge conflicts message, and select **Resolve conflicts**. - GitLab shows a list of files with merge conflicts. The conflicts are + GitLab shows a list of files with merge conflicts. The lines that conflict are highlighted: - ![Conflict section](img/conflict_section.png) + ![Conflict section](img/conflict_section_v16_7.png) + 1. For each conflict, select **Use ours** or **Use theirs** to mark the version of the conflicted lines you want to keep. This decision is known as "resolving the conflict." -1. Enter a **Commit message**. +1. When you've resolved all of the conflicts, enter a **Commit message**. 1. Select **Commit to source branch**. Resolving conflicts merges the target branch of the merge request into the @@ -77,27 +99,35 @@ source branch, using the version of the text you chose. If the source branch is `feature` and the target branch is `main`, these actions are similar to running `git switch feature; git merge main` locally. -## Resolve conflicts in the inline editor +### In the inline editor -Some merge conflicts are more complex, requiring you to manually modify lines to -resolve their conflicts. Use the merge conflict resolution editor to resolve complex -conflicts in the GitLab interface: +Some merge conflicts are more complex, and you must manually modify lines to +resolve their conflicts. The merge conflict resolution editor helps you resolve +these complex conflicts in the GitLab interface: 1. On the left sidebar, select **Search or go to** and find your project. -1. Select **Code > Merge requests** and find the merge request. +1. Select **Merge requests** and find the merge request. 1. Select **Overview**, and scroll to the merge request reports section. 1. Find the merge conflicts message, and select **Resolve conflicts**. GitLab shows a list of files with merge conflicts. -1. Select **Edit inline** to open the editor: - ![Merge conflict editor](img/merge_conflict_editor.png) +1. Find the file to edit manually, and scroll to the conflict block. +1. In the header for that file, select **Edit inline** to open the editor. In this + example, the conflict block begins at line 1350 and ends at line 1356: + + ![Merge conflict editor](img/merge_conflict_editor_v16_7.png) + 1. After you resolve the conflict, enter a **Commit message**. 1. Select **Commit to source branch**. -## Resolve conflicts from the command line +### From the command line While most conflicts can be resolved through the GitLab user interface, some are too complex. Complex conflicts are best fixed locally, from the command line, to give you the -most control over each change: +most control over each change. + +Prerequisites: + +- You must have permission to force push to branches. 1. Open the terminal and check out your feature branch. For example, `my-feature-branch`: @@ -114,12 +144,7 @@ most control over each change: ``` 1. Open the conflicting file in your preferred code editor. -1. Find the conflict block: - - It begins with the marker: `<<<<<<< HEAD`. - - Next, it displays your changes. - - The marker `=======` indicates the end of your changes. - - Next, it displays the latest changes in the target branch. - - The marker `>>>>>>>` indicates the end of the conflict. +1. Find the conflict block. 1. Edit the file: 1. Choose which version (before or after `=======`) you want to keep. 1. Delete the version you don't want to keep. @@ -153,25 +178,7 @@ most control over each change: 1. [Force-push](../../../topics/git/git_rebase.md#force-pushing) the changes to your remote branch. -## Merge commit strategy - -GitLab resolves conflicts by creating a merge commit in the source branch, but -does not merge it into the target branch. You can then review and test the -merge commit. Verify it contains no unintended changes and doesn't break your build. - ## Related topics - [Introduction to Git rebase and force-push](../../../topics/git/git_rebase.md) - [Git applications for visualizing the Git workflow](https://git-scm.com/downloads/guis) - - diff --git a/doc/user/project/merge_requests/img/conflict_section.png b/doc/user/project/merge_requests/img/conflict_section.png deleted file mode 100644 index cfc17013218..00000000000 Binary files a/doc/user/project/merge_requests/img/conflict_section.png and /dev/null differ diff --git a/doc/user/project/merge_requests/img/conflict_section_v16_7.png b/doc/user/project/merge_requests/img/conflict_section_v16_7.png new file mode 100644 index 00000000000..40701e46b50 Binary files /dev/null and b/doc/user/project/merge_requests/img/conflict_section_v16_7.png differ diff --git a/doc/user/project/merge_requests/img/conflicts_v16_7.png b/doc/user/project/merge_requests/img/conflicts_v16_7.png new file mode 100644 index 00000000000..1de03b5cfe0 Binary files /dev/null and b/doc/user/project/merge_requests/img/conflicts_v16_7.png differ diff --git a/doc/user/project/merge_requests/img/merge_conflict_editor.png b/doc/user/project/merge_requests/img/merge_conflict_editor.png deleted file mode 100644 index f10efbce5f5..00000000000 Binary files a/doc/user/project/merge_requests/img/merge_conflict_editor.png and /dev/null differ diff --git a/doc/user/project/merge_requests/img/merge_conflict_editor_v16_7.png b/doc/user/project/merge_requests/img/merge_conflict_editor_v16_7.png new file mode 100644 index 00000000000..b56ee2abdd7 Binary files /dev/null and b/doc/user/project/merge_requests/img/merge_conflict_editor_v16_7.png differ diff --git a/doc/user/project/merge_requests/img/merge_request_widget.png b/doc/user/project/merge_requests/img/merge_request_widget.png deleted file mode 100644 index 58562fcb034..00000000000 Binary files a/doc/user/project/merge_requests/img/merge_request_widget.png and /dev/null differ diff --git a/lib/generators/batched_background_migration/templates/queue_batched_background_migration.template b/lib/generators/batched_background_migration/templates/queue_batched_background_migration.template index df4c5382749..37d67194c59 100644 --- a/lib/generators/batched_background_migration/templates/queue_batched_background_migration.template +++ b/lib/generators/batched_background_migration/templates/queue_batched_background_migration.template @@ -19,7 +19,6 @@ class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Data :<%= table_name %>, :<%= column_name %>, job_interval: DELAY_INTERVAL, - queued_migration_version: '<%= migration_number %>', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/lib/gitlab/database/migrations/batched_background_migration_helpers.rb b/lib/gitlab/database/migrations/batched_background_migration_helpers.rb index 2db03b15770..39706582e3c 100644 --- a/lib/gitlab/database/migrations/batched_background_migration_helpers.rb +++ b/lib/gitlab/database/migrations/batched_background_migration_helpers.rb @@ -38,10 +38,6 @@ module Gitlab # batch_class_name - The name of the class that will be called to find the range of each next batch # batch_size - The maximum number of rows per job # sub_batch_size - The maximum number of rows processed per "iteration" within the job - # queued_migration_version - Version of the migration that queues the BBM, this is used to establish dependecies - # - # queued_migration_version is made optional temporarily to allow prior migrations to not fail, - # https://gitlab.com/gitlab-org/gitlab/-/issues/426417 will make it mandatory. # # *Returns the created BatchedMigration record* # @@ -67,7 +63,6 @@ module Gitlab batch_column_name, *job_arguments, job_interval:, - queued_migration_version: nil, batch_min_value: BATCH_MIN_VALUE, batch_max_value: nil, batch_class_name: BATCH_CLASS_NAME, @@ -80,6 +75,8 @@ module Gitlab Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_dml_mode! gitlab_schema ||= gitlab_schema_from_context + # Version of the migration that queued the BBM, this is used to establish dependencies + queued_migration_version = version Gitlab::Database::BackgroundMigration::BatchedMigration.reset_column_information @@ -120,7 +117,7 @@ module Gitlab "(given #{job_arguments.count}, expected #{migration.job_class.job_arguments_count})" end - assign_attribtues_safely( + assign_attributes_safely( migration, max_batch_size, batch_table_name, @@ -246,7 +243,7 @@ module Gitlab # about columns introduced later on because this model is not # isolated in migrations, which is why we need to check for existence # of these columns first. - def assign_attribtues_safely(migration, max_batch_size, batch_table_name, gitlab_schema, queued_migration_version) + def assign_attributes_safely(migration, max_batch_size, batch_table_name, gitlab_schema, queued_migration_version) # We keep track of the estimated number of tuples in 'total_tuple_count' to reason later # about the overall progress of a migration. safe_attributes_value = { diff --git a/spec/features/groups/clusters/user_spec.rb b/spec/features/groups/clusters/user_spec.rb index aff3e4574ca..00ba4e636ff 100644 --- a/spec/features/groups/clusters/user_spec.rb +++ b/spec/features/groups/clusters/user_spec.rb @@ -121,5 +121,24 @@ RSpec.describe 'User Cluster', :js, feature_category: :environment_management do expect(page).to have_content('Kubernetes cluster integration was successfully removed.') end end + + context 'when signed in user is an admin in admin_mode' do + let(:admin) { create(:admin) } + + before do + # signs out the user with `maintainer` role in the project + gitlab_sign_out + + gitlab_sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) + + visit group_clusters_path(group) + end + + it 'can visit the clusters index page', :aggregate_failures do + expect(page).to have_title("Kubernetes Clusters · #{group.name} · GitLab") + expect(page).to have_content('Connect a cluster') + end + end end end diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb index e256b44c4dc..b6848b10013 100644 --- a/spec/features/projects/clusters/user_spec.rb +++ b/spec/features/projects/clusters/user_spec.rb @@ -111,4 +111,23 @@ RSpec.describe 'User Cluster', :js, feature_category: :deployment_management do end end end + + context 'when signed in user is an admin in admin_mode' do + let(:admin) { create(:admin) } + + before do + # signs out the user with `maintainer` role in the project + gitlab_sign_out + + gitlab_sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) + + visit project_clusters_path(project) + end + + it 'can visit the clusters index page', :aggregate_failures do + expect(page).to have_title("Kubernetes Clusters · #{project.full_name} · GitLab") + expect(page).to have_content('Connect a cluster') + end + end end diff --git a/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt b/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt index 36f7885b591..d1fab7cf4bd 100644 --- a/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt +++ b/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt @@ -19,7 +19,6 @@ class QueueMyBatchedMigration < Gitlab::Database::Migration[2.2] :projects, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb b/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb index a81ccf9583a..5c98379d852 100644 --- a/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb @@ -71,8 +71,11 @@ RSpec.describe Gitlab::Database::Migrations::BatchedBackgroundMigrationHelpers, end context "when the migration doesn't exist already" do + let(:version) { '20231204101122' } + before do allow(Gitlab::Database::PgClass).to receive(:for_table).with(:projects).and_return(pgclass_info) + allow(migration).to receive(:version).and_return(version) end subject(:enqueue_batched_background_migration) do @@ -81,7 +84,6 @@ RSpec.describe Gitlab::Database::Migrations::BatchedBackgroundMigrationHelpers, :projects, :id, job_interval: 5.minutes, - queued_migration_version: format("%.14d", 123), batch_min_value: 5, batch_max_value: 1000, batch_class_name: 'MyBatchClass', @@ -115,7 +117,7 @@ RSpec.describe Gitlab::Database::Migrations::BatchedBackgroundMigrationHelpers, status_name: :active, total_tuple_count: pgclass_info.cardinality_estimate, gitlab_schema: 'gitlab_ci', - queued_migration_version: format("%.14d", 123) + queued_migration_version: version ) end end -- cgit v1.2.3