summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 21:09:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 21:09:55 +0000
commit540020f8155ff0686ae9a51a16414661e3cdaf9d (patch)
treee2cd6d30a944e09421137b3fda74370c0dfe33e1
parent128d4d89e98177996d1ff6e0b3d7a8a0c9b35929 (diff)
downloadgitlab-ce-540020f8155ff0686ae9a51a16414661e3cdaf9d.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/build-images.gitlab-ci.yml13
-rw-r--r--.gitlab/ci/frontend.gitlab-ci.yml8
-rw-r--r--.gitlab/ci/review-apps/qa.gitlab-ci.yml4
-rw-r--r--doc/development/database/batched_background_migrations.md71
-rw-r--r--doc/policy/alpha-beta-support.md2
-rw-r--r--package.json2
-rwxr-xr-xscripts/checkout-mr-source-sha7
-rw-r--r--yarn.lock8
8 files changed, 92 insertions, 23 deletions
diff --git a/.gitlab/ci/build-images.gitlab-ci.yml b/.gitlab/ci/build-images.gitlab-ci.yml
index c8c1557bbd9..3b360d66b7f 100644
--- a/.gitlab/ci/build-images.gitlab-ci.yml
+++ b/.gitlab/ci/build-images.gitlab-ci.yml
@@ -1,16 +1,9 @@
.base-image-build:
extends: .use-kaniko
+ variables:
+ GIT_LFS_SKIP_SMUDGE: 1
script:
- # With .git/hooks/post-checkout in place, Git tries to pull LFS objects, but the image doesn't have Git LFS, and we actually don't care about it for this specific so we just remove the file.
- # Without removing the file, the error is as follows: "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout."
- - rm -f .git/hooks/post-checkout
- - if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" ]; then
- echo "Checking out \$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA ($CI_MERGE_REQUEST_SOURCE_BRANCH_SHA) instead of \$CI_COMMIT_SHA (merge result commit $CI_COMMIT_SHA) so that GitLab image built in omnibus-gitlab-mirror and QA image are in sync.";
- git checkout -f ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA};
- else
- echo "Building the image from \$CI_COMMIT_SHA ($CI_COMMIT_SHA) for this non-merge result pipeline.";
- fi;
- - echo "See https://docs.gitlab.com/ee/development/testing_guide/end_to_end/index.html#with-pipeline-for-merged-results for more details.";
+ - scripts/checkout-mr-source-sha
retry: 2
# This image is used by:
diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml
index a7c103bae13..8c49d5c212a 100644
--- a/.gitlab/ci/frontend.gitlab-ci.yml
+++ b/.gitlab/ci/frontend.gitlab-ci.yml
@@ -43,13 +43,7 @@ compile-production-assets:
- webpack-report/
when: always
before_script:
- - if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" ]; then
- echo "Checking out \$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA ($CI_MERGE_REQUEST_SOURCE_BRANCH_SHA) instead of \$CI_COMMIT_SHA (merge result commit $CI_COMMIT_SHA) so that GitLab assets image tag actually reflect the commit for which assets were compiled.";
- git checkout -f ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA};
- else
- echo "Building the image from \$CI_COMMIT_SHA ($CI_COMMIT_SHA) for this non-merge result pipeline.";
- fi;
- - echo "See https://docs.gitlab.com/ee/development/testing_guide/end_to_end/index.html#with-pipeline-for-merged-results for more details.";
+ - scripts/checkout-mr-source-sha
- !reference [.default-before_script, before_script]
after_script:
- rm -f /etc/apt/sources.list.d/google*.list # We don't need to update Chrome here
diff --git a/.gitlab/ci/review-apps/qa.gitlab-ci.yml b/.gitlab/ci/review-apps/qa.gitlab-ci.yml
index 822f388f96f..8c48e803ad3 100644
--- a/.gitlab/ci/review-apps/qa.gitlab-ci.yml
+++ b/.gitlab/ci/review-apps/qa.gitlab-ci.yml
@@ -39,7 +39,11 @@ include:
DOCKER_TLS_CERTDIR: /certs
DOCKER_CERT_PATH: /certs/client
DOCKER_TLS_VERIFY: 1
+ GIT_LFS_SKIP_SMUDGE: 1
WD_INSTALL_DIR: /usr/local/bin
+ before_script:
+ - scripts/checkout-mr-source-sha
+ - !reference [.bundle-base, before_script]
script:
- export EE_LICENSE="$(cat $REVIEW_APPS_EE_LICENSE_FILE)"
- qa_run_status=0
diff --git a/doc/development/database/batched_background_migrations.md b/doc/development/database/batched_background_migrations.md
index f5393b26a32..f3ea82b5c61 100644
--- a/doc/development/database/batched_background_migrations.md
+++ b/doc/development/database/batched_background_migrations.md
@@ -374,6 +374,77 @@ module Gitlab
end
```
+### Adding filters to the initial batching
+
+By default, when creating background jobs to perform the migration, batched background migrations will iterate over the full specified table. This is done using the [`PrimaryKeyBatchingStrategy`](https://gitlab.com/gitlab-org/gitlab/-/blob/c9dabd1f4b8058eece6d8cb4af95e9560da9a2ee/lib/gitlab/database/migrations/batched_background_migration_helpers.rb#L17). This means if there are 1000 records in the table and the batch size is 100, there will be 10 jobs. For illustrative purposes, `EachBatch` is used like this:
+
+```ruby
+# PrimaryKeyBatchingStrategy
+Projects.all.each_batch(of: 100) do |relation|
+ relation.where(foo: nil).update_all(foo: 'bar') # this happens in each background job
+end
+```
+
+There are cases where we only need to look at a subset of records. Perhaps we only need to update 1 out of every 10 of those 1000 records. It would be best if we could apply a filter to the initial relation when the jobs are created:
+
+```ruby
+Projects.where(foo: nil).each_batch(of: 100) do |relation|
+ relation.update_all(foo: 'bar')
+end
+```
+
+In the `PrimaryKeyBatchingStrategy` example, we do not know how many records will be updated in each batch. In the filtered example, we know exactly 100 will be updated with each batch.
+
+The `PrimaryKeyBatchingStrategy` contains [a method that can be overwritten](https://gitlab.com/gitlab-org/gitlab/-/blob/dd1e70d3676891025534dc4a1e89ca9383178fe7/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy.rb#L38-52) to apply additional filtering on the initial `EachBatch`.
+
+We can accomplish this by:
+
+1. Create a new class that inherits from `PrimaryKeyBatchingStrategy` and overrides the method using the desired filter (this may be the same filter used in the sub-batch):
+
+ ```ruby
+ # frozen_string_literal: true
+
+ module GitLab
+ module BackgroundMigration
+ module BatchingStrategies
+ class FooStrategy < PrimaryKeyBatchingStrategy
+ def apply_additional_filters(relation, job_arguments: [], job_class: nil)
+ relation.where(foo: nil)
+ end
+ end
+ end
+ end
+ end
+ ```
+
+1. In the post-deployment migration that queues the batched background migration, specify the new batching strategy using the `batch_class_name` parameter:
+
+ ```ruby
+ class BackfillProjectsFoo < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'BackfillProjectsFoo'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_CLASS_NAME = 'FooStrategy'
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :routes,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_class_name: BATCH_CLASS_NAME
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :routes, :id, [])
+ end
+ end
+ ```
+
+When applying a batching strategy, it is important to ensure the filter properly covered by an index to optimize `EachBatch` performance. See [the `EachBatch` docs for more information](../iterating_tables_in_batches.md).
+
## Testing
Writing tests is required for:
diff --git a/doc/policy/alpha-beta-support.md b/doc/policy/alpha-beta-support.md
index eac9c3efb36..45f14e4f9a2 100644
--- a/doc/policy/alpha-beta-support.md
+++ b/doc/policy/alpha-beta-support.md
@@ -8,7 +8,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Support for Alpha, Beta, Limited Availability, and Generally Available Features **(PREMIUM)**
-Some GitLab features are released as [Alpha or Beta versions](https://about.gitlab.com/support/statement-of-support.html#alpha--beta-features) which are not fully supported. All other features are considered to be Generally Available (GA).
+Some GitLab features are released as [Alpha or Beta versions](https://about.gitlab.com/support/statement-of-support/#alpha-beta-features) which are not fully supported. All other features are considered to be Generally Available (GA).
## Alpha Features
diff --git a/package.json b/package.json
index 1f3c72d600a..2924ef910d3 100644
--- a/package.json
+++ b/package.json
@@ -102,7 +102,7 @@
"codesandbox-api": "0.0.23",
"compression-webpack-plugin": "^5.0.2",
"copy-webpack-plugin": "^6.4.1",
- "core-js": "^3.23.4",
+ "core-js": "^3.23.5",
"cron-validator": "^1.1.1",
"cronstrue": "^1.122.0",
"cropper": "^2.3.0",
diff --git a/scripts/checkout-mr-source-sha b/scripts/checkout-mr-source-sha
new file mode 100755
index 00000000000..962e3f1348d
--- /dev/null
+++ b/scripts/checkout-mr-source-sha
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" ]; then
+ echo "Checking out \$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA ($CI_MERGE_REQUEST_SOURCE_BRANCH_SHA) instead of \$CI_COMMIT_SHA (merge result commit $CI_COMMIT_SHA) so that code is in sync with gitlab images built upstream."
+ echo "See https://docs.gitlab.com/ee/development/testing_guide/end_to_end/index.html#with-pipeline-for-merged-results for more details."
+ git checkout -f ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}
+fi
diff --git a/yarn.lock b/yarn.lock
index 29240a4e910..45b79207b6b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3966,10 +3966,10 @@ core-js-pure@^3.0.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813"
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==
-core-js@^3.23.4:
- version "3.23.4"
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.4.tgz#92d640faa7f48b90bbd5da239986602cfc402aa6"
- integrity sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==
+core-js@^3.23.5:
+ version "3.23.5"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.5.tgz#1f82b0de5eece800827a2f59d597509c67650475"
+ integrity sha512-7Vh11tujtAZy82da4duVreQysIoO2EvVrur7y6IzZkH1IHPSekuDi8Vuw1+YKjkbfWLRD7Nc9ICQ/sIUDutcyg==
core-js@~2.3.0:
version "2.3.0"