diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 18:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 18:09:16 +0300 |
commit | 18d5458781b21dee4dbb8854c72c064e9bd808ed (patch) | |
tree | 73cfc86a9b77398a154ebabebc054b45d4aeb83d | |
parent | a21091270d45530468f8ac2f4f926fe1b9840b67 (diff) |
Add latest changes from gitlab-org/gitlab@master
35 files changed, 214 insertions, 151 deletions
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 975554f59e3..718b4e67f4e 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -181,8 +181,7 @@ - ".gitlab/ci/build-images.gitlab-ci.yml" - ".gitlab/ci/review.gitlab-ci.yml" - ".gitlab/ci/review-apps/**/*" - - "scripts/review_apps/base-config.yaml" - - "scripts/review_apps/review-apps.sh" + - "scripts/review_apps/**/*" - "scripts/trigger-build.rb" - "{,ee/,jh/}{bin,config}/**/*.rb" @@ -344,14 +343,15 @@ # DB patterns + .ci-patterns .db-patterns: &db-patterns - "{,ee/,jh/}{,spec/}{db,migrations}/**/*" - - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/database/**/*" - - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/database{,_spec}.rb" - - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/background_migration/**/*" - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/background_migration{,_spec}.rb" + - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/background_migration/**/*" + - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/content_security_policy/config_loader{,_spec}.rb" + - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/database{,_spec}.rb" + - "{,ee/,jh/}{,spec/}lib/{,ee/,jh/}gitlab/database/**/*" - "{,ee/,jh/}spec/support/helpers/database/**/*" - "{,ee/,jh/}spec/support/helpers/migrations_helpers/**/*" - - "lib/gitlab/markdown_cache/active_record/**/*" - "lib/api/admin/batched_background_migrations.rb" + - "lib/gitlab/markdown_cache/active_record/**/*" - "spec/requests/api/admin/batched_background_migrations_spec.rb" - "config/prometheus/common_metrics.yml" # Used by Gitlab::DatabaseImporters::CommonMetrics::Importer - "{,ee/,jh/}app/models/project_statistics.rb" # Used to calculate sizes in migration specs diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index e65521e892a..6d84c4f035d 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -1d669a6318f40ac765abc82e9064e9479fc22540 +ba63ee19fb2dafe6f2ca5bca5d12a0b24837ce17 diff --git a/app/assets/javascripts/pages/projects/merge_requests/index/index.js b/app/assets/javascripts/pages/projects/merge_requests/index/index.js index b3a09cc0be3..af75c05b300 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/index/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/index/index.js @@ -5,7 +5,6 @@ import { FILTERED_SEARCH } from '~/filtered_search/constants'; import { initBulkUpdateSidebar, initCsvImportExportButtons, initIssuableByEmail } from '~/issuable'; import { ISSUABLE_INDEX } from '~/issuable/constants'; import initFilteredSearch from '~/pages/search/init_filtered_search'; -import UsersSelect from '~/users_select'; initBulkUpdateSidebar(ISSUABLE_INDEX.MERGE_REQUEST); @@ -18,7 +17,6 @@ initFilteredSearch({ useDefaultState: true, }); -new UsersSelect(); // eslint-disable-line no-new new ShortcutsNavigation(); // eslint-disable-line no-new initIssuableByEmail(); diff --git a/app/assets/javascripts/sidebar/components/date/sidebar_date_widget.vue b/app/assets/javascripts/sidebar/components/date/sidebar_date_widget.vue index eb48732f558..3bc65e02ce4 100644 --- a/app/assets/javascripts/sidebar/components/date/sidebar_date_widget.vue +++ b/app/assets/javascripts/sidebar/components/date/sidebar_date_widget.vue @@ -235,7 +235,7 @@ export default { help: __('Help'), learnMore: __('Learn more'), }, - dateHelpUrl: '/help/user/group/epics/index.md#start-date-and-due-date', + dateHelpUrl: '/help/user/group/epics/manage_epics.md#start-and-due-date-inheritance', }; </script> diff --git a/app/assets/javascripts/vue_merge_request_widget/components/widget/widget.vue b/app/assets/javascripts/vue_merge_request_widget/components/widget/widget.vue index c52d5ee6e08..6003aa40c6d 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/widget/widget.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/widget/widget.vue @@ -97,6 +97,23 @@ export default { type: Boolean, required: true, }, + /** + * A button is composed of the following properties: + * + * { + * "id": string, + * "href": string, + * "dataMethod": string, + * "dataClipboardText": string, + * "icon": string, + * "variant": string, + * "loading": boolean, + * "testId":string, + * "text": string, + * "class": string | Object, + * "fullReport": boolean, + * } + */ actionButtons: { type: Array, required: false, diff --git a/app/graphql/types/ci/runner_upgrade_status_enum.rb b/app/graphql/types/ci/runner_upgrade_status_enum.rb index 34a931c8f79..668970aaff2 100644 --- a/app/graphql/types/ci/runner_upgrade_status_enum.rb +++ b/app/graphql/types/ci/runner_upgrade_status_enum.rb @@ -5,13 +5,13 @@ module Types class RunnerUpgradeStatusEnum < BaseEnum graphql_name 'CiRunnerUpgradeStatus' + MODEL_STATUS_TO_GRAPHQL_TRANSLATIONS = { + invalid_version: :invalid, + unavailable: :not_available + }.freeze + ::Ci::RunnerVersion::STATUS_DESCRIPTIONS.each do |status, description| - status_name_src = - if status == :invalid_version - :invalid - else - status - end + status_name_src = MODEL_STATUS_TO_GRAPHQL_TRANSLATIONS.fetch(status, status) value status_name_src.to_s.upcase, description: description, value: status end diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index 60796e628a3..46777ad16d0 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -91,6 +91,15 @@ module NamespacesHelper } end + def storage_usage_app_data(namespace) + { + namespace_id: namespace.id, + namespace_path: namespace.full_path, + user_namespace: namespace.user_namespace?.to_s, + default_per_page: page_size + } + end + private # Many importers create a temporary Group, so use the real diff --git a/app/models/ci/runner_version.rb b/app/models/ci/runner_version.rb index 7b26bd8d80e..ec42f46b165 100644 --- a/app/models/ci/runner_version.rb +++ b/app/models/ci/runner_version.rb @@ -8,26 +8,23 @@ module Ci enum_with_nil status: { not_processed: nil, invalid_version: -1, - not_available: 1, + unavailable: 1, available: 2, recommended: 3 } STATUS_DESCRIPTIONS = { invalid_version: 'Runner version is not valid.', - not_available: 'Upgrade is not available for the runner.', + unavailable: 'Upgrade is not available for the runner.', available: 'Upgrade is available for the runner.', recommended: 'Upgrade is available and recommended for the runner.' }.freeze has_many :runner_machines, inverse_of: :runner_version, foreign_key: :version, class_name: 'Ci::RunnerMachine' - # Override auto generated negative scope (from available) so the scope has expected behavior - scope :not_available, -> { where(status: :not_available) } - # This scope returns all versions that might need recalculating. For instance, once a version is considered # :recommended, it normally doesn't change status even if the instance is upgraded - scope :potentially_outdated, -> { where(status: [nil, :not_available, :available]) } + scope :potentially_outdated, -> { where(status: [nil, :unavailable, :available]) } validates :version, length: { maximum: 2048 } end diff --git a/app/models/release.rb b/app/models/release.rb index 85699d259f5..0f00732b62e 100644 --- a/app/models/release.rb +++ b/app/models/release.rb @@ -25,7 +25,7 @@ class Release < ApplicationRecord before_create :set_released_at validates :project, :tag, presence: true - validates :author_id, presence: true, on: :create, if: :validate_release_with_author? + validates :author_id, presence: true, on: :create validates :tag, uniqueness: { scope: :project_id } @@ -118,10 +118,6 @@ class Release < ApplicationRecord end end - def validate_release_with_author? - Feature.enabled?(:validate_release_with_author, self.project) - end - def set_released_at self.released_at ||= created_at end diff --git a/app/views/search/_results_status.html.haml b/app/views/search/_results_status.html.haml index af65ac0d1a8..27405631360 100644 --- a/app/views/search/_results_status.html.haml +++ b/app/views/search/_results_status.html.haml @@ -3,12 +3,12 @@ .search-results-status .gl-display-flex.gl-flex-direction-column .gl-p-5.gl-display-flex - .gl-md-display-flex.gl-text-left.gl-align-items-center.gl-flex-grow-1 + .gl-md-display-flex.gl-text-left.gl-align-items-center.gl-flex-grow-1.gl-white-space-nowrap.gl-max-w-full - unless @search_service_presenter.without_count? = search_entries_info(@search_objects, @scope, @search_term) - unless @search_service_presenter.show_snippets? - if @project - - link_to_project = link_to(@project.full_name, @project, class: 'ml-md-1') + - link_to_project = link_to(@project.full_name, @project, class: 'ml-md-1 gl-text-truncate search-wrap-f-md-down') - if @scope == 'blobs' = _("in") .mx-md-1 diff --git a/config/feature_flags/development/validate_release_with_author.yml b/config/feature_flags/development/validate_release_with_author.yml deleted file mode 100644 index bac23edfa89..00000000000 --- a/config/feature_flags/development/validate_release_with_author.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: validate_release_with_author -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89694 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/365350 -milestone: '15.1' -type: development -group: group::release -default_enabled: true diff --git a/db/post_migrate/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb b/db/post_migrate/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb new file mode 100644 index 00000000000..778510e9fcb --- /dev/null +++ b/db/post_migrate/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class ScheduleTmpIndexToCiBuildReportResults < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = :tmp_index_ci_build_report_results_on_partition_id_and_build_id + TABLE_NAME = :ci_build_report_results + + def up + return unless Gitlab.com? + + prepare_async_index(TABLE_NAME, [:partition_id, :build_id], where: 'partition_id = 101', name: INDEX_NAME) + end + + def down + return unless Gitlab.com? + + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/schema_migrations/20230130075434 b/db/schema_migrations/20230130075434 new file mode 100644 index 00000000000..d31dafc4739 --- /dev/null +++ b/db/schema_migrations/20230130075434 @@ -0,0 +1 @@ +897f84696379e25d1aba5956db63dd1f4696a546d4c3a4742f0aa8b8eaecdbf6
\ No newline at end of file diff --git a/doc/administration/raketasks/check.md b/doc/administration/raketasks/check.md index 2660caa80b3..2cb664b0859 100644 --- a/doc/administration/raketasks/check.md +++ b/doc/administration/raketasks/check.md @@ -381,3 +381,37 @@ To delete these references to missing local and/or remote artifacts (`job.log` f If `gitlab-rake gitlab:lfs:check VERBOSE=1` detects LFS objects that exist in the database but not on disk, [follow the procedure in the LFS documentation](../lfs/index.md#missing-lfs-objects) to remove the database entries. + +### Update dangling object storage references + +If you have [migrated from object storage to local storage](../job_artifacts.md#migrating-from-object-storage-to-local-storage) and files were missing, then dangling database references remain. + +This is visible in the migration logs with errors like the following: + +```shell +W, [2022-11-28T13:14:09.283833 #10025] WARN -- : Failed to transfer Ci::JobArtifact ID 11 with error: undefined method `body' for nil:NilClass +W, [2022-11-28T13:14:09.296911 #10025] WARN -- : Failed to transfer Ci::JobArtifact ID 12 with error: undefined method `body' for nil:NilClass +``` + +Attempting to [delete references to missing artifacts](check.md#delete-references-to-missing-artifacts) after you have disabled object storage, results in the following error: + +```shell +RuntimeError (Object Storage is not enabled for JobArtifactUploader) +``` + +To update these references to point to local storage: + +1. Open the [GitLab Rails Console](../operations/rails_console.md#starting-a-rails-console-session). +1. Run the following Ruby code: + + ```ruby + artifacts_updated = 0 + ::Ci::JobArtifact.find_each do |artifact| ### Iterate artifacts + next if artifact.file_store != 2 ### Skip if file_store already points to local storage + artifacts_updated += 1 + # artifact.update(file_store: 1) ### Uncomment to actually update + end + puts "Updated file_store count: #{artifacts_updated}" + ``` + +The script to [delete references to missing artifacts](check.md#delete-references-to-missing-artifacts) now functions correctly and cleans up the database. diff --git a/doc/development/feature_categorization/index.md b/doc/development/feature_categorization/index.md index ff8c149e631..26c2c553d59 100644 --- a/doc/development/feature_categorization/index.md +++ b/doc/development/feature_categorization/index.md @@ -191,7 +191,7 @@ within that class. You must set feature category metadata for each RSpec example. This information is used for flaky test issues to identify the group that owns the feature. -The `feature_category` should be a value from [`categories.json`](https://about.gitlab.com/categories.json). +The `feature_category` should be a value from [`config/feature_categories.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/feature_categories.yml). The `feature_category` metadata can be set: diff --git a/doc/update/index.md b/doc/update/index.md index b1d72183582..b09ba691081 100644 --- a/doc/update/index.md +++ b/doc/update/index.md @@ -177,7 +177,6 @@ upgraded to. This is to ensure [compatibility with GitLab versions](https://docs ## Upgrade paths Upgrading across multiple GitLab versions in one go is *only possible by accepting downtime*. -The following examples assume downtime is acceptable while upgrading. If you don't want any downtime, read how to [upgrade with zero downtime](zero_downtime.md). For a dynamic view of examples of supported upgrade paths, try the [Upgrade Path tool](https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/) maintained by the [GitLab Support team](https://about.gitlab.com/handbook/support/#about-the-support-team). To share feedback and help improve the tool, create an issue or MR in the [upgrade-path project](https://gitlab.com/gitlab-com/support/toolbox/upgrade-path). @@ -186,7 +185,14 @@ Find where your version sits in the upgrade path below, and upgrade GitLab accordingly, while also consulting the [version-specific upgrade instructions](#version-specific-upgrading-instructions): -`8.11.Z` -> `8.12.0` -> `8.17.7` -> `9.0.13` -> `9.5.10` -> `10.0.7` -> `10.8.7` -> `11.0.6` -> [`11.11.8`](#1200) -> `12.0.12` -> [`12.1.17`](#1210) -> [`12.10.14`](#12100) -> `13.0.14` -> [`13.1.11`](#1310) -> [`13.8.8`](#1388) -> [`13.12.15`](#13120) -> [`14.0.12`](#1400) -> [`14.3.6`](#1430) -> [`14.9.5`](#1490) -> [`14.10.Z`](#14100) -> [`15.0.Z`](#1500) -> [`15.1.Z`](#1510) (for GitLab instances with multiple web nodes) -> [`15.4.0`](#1540) -> [latest `15.Y.Z`](https://gitlab.com/gitlab-org/gitlab/-/releases) +- GitLab 8: `8.11.Z` > `8.12.0` > `8.17.7` +- GitLab 9: `9.0.13` > `9.5.10` +- GitLab 10: `10.0.7` > `10.8.7` +- GitLab 11: `11.0.6` > [`11.11.8`](#1200) +- GitLab 12: `12.0.12` > [`12.1.17`](#1210) > [`12.10.14`](#12100) +- GitLab 13: `13.0.14` > [`13.1.11`](#1310) > [`13.8.8`](#1388) > [`13.12.15`](#13120) +- GitLab 14: [`14.0.12`](#1400) > [`14.3.6`](#1430) > [`14.9.5`](#1490) > [`14.10.5`](#14100) +- GitLab 15: [`15.0.5`](#1500) > [`15.1.6`](#1510) (for GitLab instances with multiple web nodes) > [`15.4.6`](#1540) > [latest `15.Y.Z`](https://gitlab.com/gitlab-org/gitlab/-/releases) NOTE: When not explicitly specified, upgrade GitLab to the latest available patch @@ -196,23 +202,6 @@ be fixes for issues relating to the upgrade process. Specifically around a [major version](#upgrading-to-a-new-major-version), crucial database schema and migration patches are included in the latest patch releases. -The following table, while not exhaustive, shows some examples of the supported -upgrade paths. -Additional steps between the mentioned versions are possible. We list the minimally necessary steps only. - -| Target version | Your version | Supported upgrade path | Note | -| -------------- | ------------ | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `15.1.0` | `14.6.2` | `14.6.2` -> `14.9.5` -> `14.10.5` -> `15.0.2` -> `15.1.0` | Three intermediate versions are required: `14.9`, `14.10`, and `15.0`. | -| `15.0.0` | `14.6.2` | `14.6.2` -> `14.9.5` -> `14.10.5` -> `15.0.2` | Two intermediate versions are required: `14.9` and `14.10`. | -| `14.6.2` | `13.10.2` | `13.10.2` -> `13.12.15` -> `14.0.12` -> `14.3.6` => `14.6.2` | Three intermediate versions are required: `13.12`, `14.0`, and `14.3`. | -| `14.1.8` | `13.9.2` | `13.9.2` -> `13.12.15` -> `14.0.12` -> `14.1.8` | Two intermediate versions are required: `13.12` and `14.0`. | -| `13.12.15` | `12.9.2` | `12.9.2` -> `12.10.14` -> `13.0.14` -> `13.1.11` -> `13.8.8` -> `13.12.15` | Four intermediate versions are required: `12.10`, `13.0`, `13.1`, and `13.8`. | -| `13.2.10` | `11.5.0` | `11.5.0` -> `11.11.8` -> `12.0.12` -> `12.1.17` -> `12.10.14` -> `13.0.14` -> `13.1.11` -> `13.2.10` | Six intermediate versions are required: `11.11`, `12.0`, `12.1`, `12.10`, `13.0`, and `13.1`. | -| `12.10.14` | `11.3.4` | `11.3.4` -> `11.11.8` -> `12.0.12` -> `12.1.17` -> `12.10.14` | Three intermediate versions are required: `11.11`, `12.0`, and `12.1`. | -| `12.9.5` | `10.4.5` | `10.4.5` -> `10.8.7` -> `11.0.6` -> `11.11.8` -> `12.0.12` -> `12.1.17` -> `12.9.5` | Five intermediate versions are required: `10.8`, `11.0`, `11.11`, `12.0`, and `12.1`. | -| `12.2.5` | `9.2.6` | `9.2.6` -> `9.5.10` -> `10.0.7` -> `10.8.7` -> `11.0.6` -> `11.11.8` -> `12.0.12` -> `12.1.17` -> `12.2.5` | Seven intermediate versions are required: `9.5`, `10.0`, `10.8`, `11.0`, `11.11`, `12.0`, and `12.1`. | -| `11.3.4` | `8.13.4` | `8.13.4` -> `8.17.7` -> `9.0.13` -> `9.5.10` -> `10.0.7` -> `10.8.7` -> `11.0.6` -> `11.3.4` | Six intermediate versions are required: `8.17`, `9.0`, `9.5`, `10.0`, `10.8`, and `11.0`. | - ## Upgrading between editions GitLab comes in two flavors: [Community Edition](https://about.gitlab.com/features/#community) which is MIT licensed, diff --git a/lib/bulk_imports/error.rb b/lib/bulk_imports/error.rb index 127eca4dba6..4699d5eab5f 100644 --- a/lib/bulk_imports/error.rb +++ b/lib/bulk_imports/error.rb @@ -3,7 +3,8 @@ module BulkImports class Error < StandardError def self.unsupported_gitlab_version - self.new("Unsupported GitLab Version. Minimum Supported Gitlab Version #{BulkImport::MIN_MAJOR_VERSION}.") + self.new("Unsupported GitLab version. Source instance must run GitLab version #{BulkImport::MIN_MAJOR_VERSION} " \ + "or later.") end def self.scope_validation_failure diff --git a/lib/gitlab/ci/runner_upgrade_check.rb b/lib/gitlab/ci/runner_upgrade_check.rb index 03130addd6a..19a8dc446d4 100644 --- a/lib/gitlab/ci/runner_upgrade_check.rb +++ b/lib/gitlab/ci/runner_upgrade_check.rb @@ -42,7 +42,7 @@ module Gitlab # Consider update if there's a newer release within the currently deployed GitLab version add_available_runner_release(runner_version, suggestions) - suggestions[runner_version] = :not_available if suggestions.empty? + suggestions[runner_version] = :unavailable if suggestions.empty? suggestions end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index fc5de91dfac..05c1f491aee 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -36555,6 +36555,9 @@ msgstr "" msgid "Runners|Members of the %{type} can register runners" msgstr "" +msgid "Runners|Minor version upgrades are available." +msgstr "" + msgid "Runners|Name" msgstr "" @@ -36758,6 +36761,9 @@ msgstr "" msgid "Runners|Runs untagged jobs" msgstr "" +msgid "Runners|Security or compatibility upgrades are recommended." +msgstr "" + msgid "Runners|Select all" msgstr "" diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb index 5bd8eec55b7..379499662c2 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb @@ -1,12 +1,8 @@ # frozen_string_literal: true module QA - RSpec.describe 'Verify', :runner, product_group: :pipeline_execution, quarantine: { - only: :production, - type: :test_environment, - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/379747' - } do - context 'When pipeline is blocked' do + RSpec.describe 'Verify', :runner, product_group: :pipeline_execution do + context 'when pipeline is blocked' do let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" } let(:project) do diff --git a/rubocop/cop/rspec/invalid_feature_category.rb b/rubocop/cop/rspec/invalid_feature_category.rb index f0789a71d63..4d658fdc36f 100644 --- a/rubocop/cop/rspec/invalid_feature_category.rb +++ b/rubocop/cop/rspec/invalid_feature_category.rb @@ -64,7 +64,7 @@ module RuboCop end # Used by RuboCop to invalidate its cache if the contents of - # config/feature_categories.json changes. + # config/feature_categories.yml changes. def external_dependency_checksum @external_dependency_checksum ||= Digest::SHA256.file(FEATURE_CATEGORIES_PATH).hexdigest diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb index 6ab42c5877a..33c7c818456 100755 --- a/scripts/review_apps/automated_cleanup.rb +++ b/scripts/review_apps/automated_cleanup.rb @@ -58,7 +58,7 @@ module ReviewApps end def helm - @helm ||= Tooling::Helm3Client.new(namespace: review_apps_namespace) + @helm ||= Tooling::Helm3Client.new end def kubernetes diff --git a/spec/finders/ci/runners_finder_spec.rb b/spec/finders/ci/runners_finder_spec.rb index 1aba77f4d6e..77260bb4c5c 100644 --- a/spec/finders/ci/runners_finder_spec.rb +++ b/spec/finders/ci/runners_finder_spec.rb @@ -60,8 +60,8 @@ RSpec.describe Ci::RunnersFinder, feature_category: :runner_fleet do create(:ci_runner_version, version: 'a', status: :recommended) end - let_it_be(:runner_version_not_available) do - create(:ci_runner_version, version: 'b', status: :not_available) + let_it_be(:runner_version_unavailable) do + create(:ci_runner_version, version: 'b', status: :unavailable) end let_it_be(:runner_version_available) do @@ -77,7 +77,7 @@ RSpec.describe Ci::RunnersFinder, feature_category: :runner_fleet do let(:upgrade_status) { status } it "calls with_upgrade_status scope with corresponding :#{status} status" do - if [:available, :not_available, :recommended].include?(status) + if [:available, :unavailable, :recommended].include?(status) expected_result = Ci::Runner.with_upgrade_status(status) end diff --git a/spec/frontend/fixtures/runner.rb b/spec/frontend/fixtures/runner.rb index de87114766e..f60e4991292 100644 --- a/spec/frontend/fixtures/runner.rb +++ b/spec/frontend/fixtures/runner.rb @@ -30,7 +30,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do before do allow_next_instance_of(::Gitlab::Ci::RunnerUpgradeCheck) do |instance| allow(instance).to receive(:check_runner_upgrade_suggestion) - .and_return([nil, :not_available]) + .and_return([nil, :unavailable]) end end diff --git a/spec/graphql/mutations/ci/job_token_scope/remove_project_spec.rb b/spec/graphql/mutations/ci/job_token_scope/remove_project_spec.rb index d399e73f394..4a0501bddbd 100644 --- a/spec/graphql/mutations/ci/job_token_scope/remove_project_spec.rb +++ b/spec/graphql/mutations/ci/job_token_scope/remove_project_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Mutations::Ci::JobTokenScope::RemoveProject do +RSpec.describe Mutations::Ci::JobTokenScope::RemoveProject, feature_category: :continuous_integration do let(:mutation) do described_class.new(object: nil, context: { current_user: current_user }, field: nil) end diff --git a/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb b/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb index ec53e5bd508..4aa9ad094a6 100644 --- a/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb +++ b/spec/graphql/types/ci/runner_upgrade_status_enum_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Types::Ci::RunnerUpgradeStatusEnum, feature_category: :runner_fle expected_graphql_source_values .map(&:upcase) .map { |v| v == 'INVALID_VERSION' ? 'INVALID' : v } + .map { |v| v == 'UNAVAILABLE' ? 'NOT_AVAILABLE' : v } ) end diff --git a/spec/lib/bulk_imports/clients/graphql_spec.rb b/spec/lib/bulk_imports/clients/graphql_spec.rb index a5b5e96e594..3ce84dbfe2f 100644 --- a/spec/lib/bulk_imports/clients/graphql_spec.rb +++ b/spec/lib/bulk_imports/clients/graphql_spec.rb @@ -34,7 +34,7 @@ RSpec.describe BulkImports::Clients::Graphql do let(:version) { '13.0.0' } it 'raises an error' do - expect { subject.execute('test') }.to raise_error(::BulkImports::Error, "Unsupported GitLab Version. Minimum Supported Gitlab Version #{BulkImport::MIN_MAJOR_VERSION}.") + expect { subject.execute('test') }.to raise_error(::BulkImports::Error, "Unsupported GitLab version. Source instance must run GitLab version #{BulkImport::MIN_MAJOR_VERSION} or later.") end end end diff --git a/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb b/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb index a07e95151d6..526d6cba657 100644 --- a/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb +++ b/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb @@ -51,8 +51,8 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck, feature_category: :runner_fleet d context 'with runner_version from last minor release' do let(:runner_version) { 'v14.0.1' } - it 'returns :not_available' do - is_expected.to eq([parsed_runner_version, :not_available]) + it 'returns :unavailable' do + is_expected.to eq([parsed_runner_version, :unavailable]) end end end @@ -85,8 +85,8 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck, feature_category: :runner_fleet d context 'with a runner_version that is too recent' do let(:runner_version) { 'v14.2.0' } - it 'returns :not_available' do - is_expected.to eq([parsed_runner_version, :not_available]) + it 'returns :unavailable' do + is_expected.to eq([parsed_runner_version, :unavailable]) end end end @@ -96,14 +96,14 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck, feature_category: :runner_fleet d context 'with valid params' do where(:runner_version, :expected_status, :expected_suggested_version) do - 'v15.0.0' | :not_available | '15.0.0' # not available since the GitLab instance is still on 14.x, a major version might be incompatible, and a patch upgrade is not available + 'v15.0.0' | :unavailable | '15.0.0' # not available since the GitLab instance is still on 14.x, a major version might be incompatible, and a patch upgrade is not available 'v14.1.0-rc3' | :recommended | '14.1.1' # recommended since even though the GitLab instance is still on 14.0.x, there is a patch release (14.1.1) available which might contain security fixes 'v14.1.0~beta.1574.gf6ea9389' | :recommended | '14.1.1' # suffixes are correctly handled 'v14.1.0/1.1.0' | :recommended | '14.1.1' # suffixes are correctly handled 'v14.1.0' | :recommended | '14.1.1' # recommended since even though the GitLab instance is still on 14.0.x, there is a patch release (14.1.1) available which might contain security fixes 'v14.0.1' | :recommended | '14.0.2' # recommended upgrade since 14.0.2 is available 'v14.0.2-rc1' | :recommended | '14.0.2' # recommended upgrade since 14.0.2 is available and we'll move out of a release candidate - 'v14.0.2' | :not_available | '14.0.2' # not available since 14.0.2 is the latest 14.0.x release available within the instance's major.minor version + 'v14.0.2' | :unavailable | '14.0.2' # not available since 14.0.2 is the latest 14.0.x release available within the instance's major.minor version 'v13.10.1' | :available | '14.0.2' # available upgrade: 14.0.2 'v13.10.1~beta.1574.gf6ea9389' | :recommended | '13.10.1' # suffixes are correctly handled, official 13.10.1 is available 'v13.10.1/1.1.0' | :recommended | '13.10.1' # suffixes are correctly handled, official 13.10.1 is available @@ -125,13 +125,13 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck, feature_category: :runner_fleet d context 'with valid params' do where(:runner_version, :expected_status, :expected_suggested_version) do - 'v14.0.0' | :recommended | '14.0.2' # recommended upgrade since 14.0.2 is available, even though the GitLab instance is still on 13.x and a major version might be incompatible - 'v13.10.1' | :not_available | '13.10.1' # not available since 13.10.1 is already ahead of GitLab instance version and is the latest patch update for 13.10.x - 'v13.10.0' | :recommended | '13.10.1' # recommended upgrade since 13.10.1 is available - 'v13.9.2' | :not_available | '13.9.2' # not_available even though backports are no longer released for this version because the runner is already on the same version as the GitLab version - 'v13.9.0' | :recommended | '13.9.2' # recommended upgrade since backports are no longer released for this version - 'v13.8.1' | :recommended | '13.9.2' # recommended upgrade since build is too old (missing in records) - 'v11.4.1' | :recommended | '13.9.2' # recommended upgrade since build is too old (missing in records) + 'v14.0.0' | :recommended | '14.0.2' # recommended upgrade since 14.0.2 is available, even though the GitLab instance is still on 13.x and a major version might be incompatible + 'v13.10.1' | :unavailable | '13.10.1' # not available since 13.10.1 is already ahead of GitLab instance version and is the latest patch update for 13.10.x + 'v13.10.0' | :recommended | '13.10.1' # recommended upgrade since 13.10.1 is available + 'v13.9.2' | :unavailable | '13.9.2' # not available even though backports are no longer released for this version because the runner is already on the same version as the GitLab version + 'v13.9.0' | :recommended | '13.9.2' # recommended upgrade since backports are no longer released for this version + 'v13.8.1' | :recommended | '13.9.2' # recommended upgrade since build is too old (missing in records) + 'v11.4.1' | :recommended | '13.9.2' # recommended upgrade since build is too old (missing in records) end with_them do diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 65dc1a71829..c75d1faf48f 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -1939,12 +1939,12 @@ RSpec.describe Ci::Runner, feature_category: :runner do let_it_be(:runner_14_1_1) { create(:ci_runner, version: '14.1.1') } let_it_be(:runner_version_14_0_0) { create(:ci_runner_version, version: '14.0.0', status: :available) } let_it_be(:runner_version_14_1_0) { create(:ci_runner_version, version: '14.1.0', status: :recommended) } - let_it_be(:runner_version_14_1_1) { create(:ci_runner_version, version: '14.1.1', status: :not_available) } + let_it_be(:runner_version_14_1_1) { create(:ci_runner_version, version: '14.1.1', status: :unavailable) } - context ':not_available' do - let(:upgrade_status) { :not_available } + context ':unavailable' do + let(:upgrade_status) { :unavailable } - it 'returns runners whose version is assigned :not_available' do + it 'returns runners whose version is assigned :unavailable' do is_expected.to contain_exactly(runner_14_1_1) end end diff --git a/spec/models/ci/runner_version_spec.rb b/spec/models/ci/runner_version_spec.rb index 3e987c8309a..51a2f14c57c 100644 --- a/spec/models/ci/runner_version_spec.rb +++ b/spec/models/ci/runner_version_spec.rb @@ -3,35 +3,35 @@ require 'spec_helper' RSpec.describe Ci::RunnerVersion, feature_category: :runner_fleet do - let_it_be(:runner_version_recommended) do + let_it_be(:runner_version_upgrade_recommended) do create(:ci_runner_version, version: 'abc234', status: :recommended) end - let_it_be(:runner_version_not_available) do - create(:ci_runner_version, version: 'abc123', status: :not_available) + let_it_be(:runner_version_upgrade_unavailable) do + create(:ci_runner_version, version: 'abc123', status: :unavailable) end it { is_expected.to have_many(:runner_machines).with_foreign_key(:version) } it_behaves_like 'having unique enum values' - describe '.not_available' do - subject { described_class.not_available } + describe '.unavailable' do + subject { described_class.unavailable } - it { is_expected.to match_array([runner_version_not_available]) } + it { is_expected.to match_array([runner_version_upgrade_unavailable]) } end describe '.potentially_outdated' do subject { described_class.potentially_outdated } let_it_be(:runner_version_nil) { create(:ci_runner_version, version: 'abc345', status: nil) } - let_it_be(:runner_version_available) do + let_it_be(:runner_version_upgrade_available) do create(:ci_runner_version, version: 'abc456', status: :available) end it 'contains any valid or unprocessed runner version that is not already recommended' do is_expected.to match_array( - [runner_version_nil, runner_version_not_available, runner_version_available] + [runner_version_nil, runner_version_upgrade_unavailable, runner_version_upgrade_available] ) end end diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb index de67ec35587..880fb21b7af 100644 --- a/spec/models/release_spec.rb +++ b/spec/models/release_spec.rb @@ -71,14 +71,6 @@ RSpec.describe Release do subject { build(:release, project: project, name: 'Release 1.0') } it { is_expected.to validate_presence_of(:author_id) } - - context 'when feature flag is disabled' do - before do - stub_feature_flags(validate_release_with_author: false) - end - - it { is_expected.not_to validate_presence_of(:author_id) } - end end # Deleting user along with their contributions, nullifies releases author_id. diff --git a/spec/services/ci/runners/process_runner_version_update_service_spec.rb b/spec/services/ci/runners/process_runner_version_update_service_spec.rb index d2a7e87b2d5..e62cb1ec3e3 100644 --- a/spec/services/ci/runners/process_runner_version_update_service_spec.rb +++ b/spec/services/ci/runners/process_runner_version_update_service_spec.rb @@ -53,14 +53,14 @@ RSpec.describe Ci::Runners::ProcessRunnerVersionUpdateService, feature_category: end context 'with existing ci_runner_version record' do - let!(:runner_version) { create(:ci_runner_version, version: '1.0.0', status: :not_available) } + let!(:runner_version) { create(:ci_runner_version, version: '1.0.0', status: :unavailable) } it 'updates ci_runner_versions record', :aggregate_failures do expect do expect(execute).to be_success expect(execute.http_status).to eq :ok expect(execute.payload).to eq({ upgrade_status: 'recommended' }) - end.to change { runner_version.reload.status }.from('not_available').to('recommended') + end.to change { runner_version.reload.status }.from('unavailable').to('recommended') end end diff --git a/spec/services/ci/runners/reconcile_existing_runner_versions_service_spec.rb b/spec/services/ci/runners/reconcile_existing_runner_versions_service_spec.rb index 39082b5c0f4..8d7e97e5ea8 100644 --- a/spec/services/ci/runners/reconcile_existing_runner_versions_service_spec.rb +++ b/spec/services/ci/runners/reconcile_existing_runner_versions_service_spec.rb @@ -9,7 +9,7 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' let_it_be(:runner_14_0_1) { create(:ci_runner, version: '14.0.1') } let_it_be(:runner_version_14_0_1) do - create(:ci_runner_version, version: '14.0.1', status: :not_available) + create(:ci_runner_version, version: '14.0.1', status: :unavailable) end context 'with RunnerUpgradeCheck recommending 14.0.2' do @@ -23,15 +23,17 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' context 'with runner with new version' do let!(:runner_14_0_2) { create(:ci_runner, version: '14.0.2') } - let!(:runner_version_14_0_0) { create(:ci_runner_version, version: '14.0.0', status: :not_available) } let!(:runner_14_0_0) { create(:ci_runner, version: '14.0.0') } + let!(:runner_version_14_0_0) do + create(:ci_runner_version, version: '14.0.0', status: :unavailable) + end before do allow(upgrade_check).to receive(:check_runner_upgrade_suggestion) .and_return([::Gitlab::VersionInfo.new(14, 0, 2), :recommended]) allow(upgrade_check).to receive(:check_runner_upgrade_suggestion) .with('14.0.2') - .and_return([::Gitlab::VersionInfo.new(14, 0, 2), :not_available]) + .and_return([::Gitlab::VersionInfo.new(14, 0, 2), :unavailable]) .once end @@ -43,9 +45,9 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' .and_call_original expect { execute } - .to change { runner_version_14_0_0.reload.status }.from('not_available').to('recommended') - .and change { runner_version_14_0_1.reload.status }.from('not_available').to('recommended') - .and change { ::Ci::RunnerVersion.find_by(version: '14.0.2')&.status }.from(nil).to('not_available') + .to change { runner_version_14_0_0.reload.status }.from('unavailable').to('recommended') + .and change { runner_version_14_0_1.reload.status }.from('unavailable').to('recommended') + .and change { ::Ci::RunnerVersion.find_by(version: '14.0.2')&.status }.from(nil).to('unavailable') expect(execute).to be_success expect(execute.payload).to eq({ @@ -57,17 +59,19 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' end context 'with orphan ci_runner_version' do - let!(:runner_version_14_0_2) { create(:ci_runner_version, version: '14.0.2', status: :not_available) } + let!(:runner_version_14_0_2) do + create(:ci_runner_version, version: '14.0.2', status: :unavailable) + end before do allow(upgrade_check).to receive(:check_runner_upgrade_suggestion) - .and_return([::Gitlab::VersionInfo.new(14, 0, 2), :not_available]) + .and_return([::Gitlab::VersionInfo.new(14, 0, 2), :unavailable]) end it 'deletes orphan ci_runner_versions entry', :aggregate_failures do expect { execute } - .to change { ::Ci::RunnerVersion.find_by_version('14.0.2')&.status }.from('not_available').to(nil) - .and not_change { runner_version_14_0_1.reload.status }.from('not_available') + .to change { ::Ci::RunnerVersion.find_by_version('14.0.2')&.status }.from('unavailable').to(nil) + .and not_change { runner_version_14_0_1.reload.status }.from('unavailable') expect(execute).to be_success expect(execute.payload).to eq({ @@ -81,11 +85,11 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' context 'with no runner version changes' do before do allow(upgrade_check).to receive(:check_runner_upgrade_suggestion) - .and_return([::Gitlab::VersionInfo.new(14, 0, 1), :not_available]) + .and_return([::Gitlab::VersionInfo.new(14, 0, 1), :unavailable]) end it 'does not modify ci_runner_versions entries', :aggregate_failures do - expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('not_available') + expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('unavailable') expect(execute).to be_success expect(execute.payload).to eq({ @@ -103,7 +107,7 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' end it 'makes no changes to ci_runner_versions', :aggregate_failures do - expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('not_available') + expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('unavailable') expect(execute).to be_success expect(execute.payload).to eq({ @@ -121,7 +125,7 @@ RSpec.describe ::Ci::Runners::ReconcileExistingRunnerVersionsService, '#execute' end it 'does not modify ci_runner_versions entries', :aggregate_failures do - expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('not_available') + expect { execute }.not_to change { runner_version_14_0_1.reload.status }.from('unavailable') expect(execute).to be_success expect(execute.payload).to eq({ diff --git a/spec/tooling/lib/tooling/helm3_client_spec.rb b/spec/tooling/lib/tooling/helm3_client_spec.rb index 52d1b5a1567..5a015ddfa7c 100644 --- a/spec/tooling/lib/tooling/helm3_client_spec.rb +++ b/spec/tooling/lib/tooling/helm3_client_spec.rb @@ -3,15 +3,14 @@ require_relative '../../../../tooling/lib/tooling/helm3_client' RSpec.describe Tooling::Helm3Client do - let(:namespace) { 'review-apps' } let(:release_name) { 'my-release' } let(:raw_helm_list_page1) do <<~OUTPUT [ - {"name":"review-qa-60-reor-1mugd1","namespace":"#{namespace}","revision":1,"updated":"2020-04-03 17:27:10.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, - {"name":"review-7846-fix-s-261vd6","namespace":"#{namespace}","revision":2,"updated":"2020-04-02 17:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, - {"name":"review-7867-snowp-lzo3iy","namespace":"#{namespace}","revision":1,"updated":"2020-04-02 15:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"}, - {"name":"review-6709-group-2pzeec","namespace":"#{namespace}","revision":2,"updated":"2020-04-01 21:27:12.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.1"} + {"name":"review-qa-60-reor-1mugd1","namespace":"review-qa-60-reor-1mugd1","revision":1,"updated":"2020-04-03 17:27:10.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, + {"name":"review-7846-fix-s-261vd6","namespace":"review-7846-fix-s-261vd6","revision":2,"updated":"2020-04-02 17:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.2"}, + {"name":"review-7867-snowp-lzo3iy","namespace":"review-7867-snowp-lzo3iy","revision":1,"updated":"2020-04-02 15:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"}, + {"name":"review-6709-group-2pzeec","namespace":"review-6709-group-2pzeec","revision":2,"updated":"2020-04-01 21:27:12.245952 +0800 +08","status":"failed","chart":"gitlab-1.1.3","app_version":"12.9.1"} ] OUTPUT end @@ -19,7 +18,7 @@ RSpec.describe Tooling::Helm3Client do let(:raw_helm_list_page2) do <<~OUTPUT [ - {"name":"review-6709-group-t40qbv","namespace":"#{namespace}","revision":2,"updated":"2020-04-01 11:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"} + {"name":"review-6709-group-t40qbv","namespace":"review-6709-group-t40qbv","revision":2,"updated":"2020-04-01 11:27:12.245952 +0800 +08","status":"deployed","chart":"gitlab-1.1.3","app_version":"12.9.1"} ] OUTPUT end @@ -30,7 +29,7 @@ RSpec.describe Tooling::Helm3Client do OUTPUT end - subject { described_class.new(namespace: namespace) } + subject { described_class.new } describe '#releases' do it 'raises an error if the Helm command fails' do @@ -74,7 +73,7 @@ RSpec.describe Tooling::Helm3Client do status: 'deployed', chart: 'gitlab-1.1.3', app_version: '12.9.1', - namespace: namespace + namespace: 'review-6709-group-t40qbv' ) end @@ -98,18 +97,19 @@ RSpec.describe Tooling::Helm3Client do describe '#delete' do it 'raises an error if the Helm command fails' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name})]) + .with([%(helm uninstall --namespace #{release_name} #{release_name})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false))) - expect { subject.delete(release_name: release_name) }.to raise_error(described_class::CommandFailedError) + expect { subject.delete(release_name: release_name, namespace: release_name) } + .to raise_error(described_class::CommandFailedError) end it 'calls helm uninstall with default arguments' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name})]) + .with([%(helm uninstall --namespace #{release_name} #{release_name})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) - expect(subject.delete(release_name: release_name)).to eq('') + subject.delete(release_name: release_name, namespace: release_name) end context 'with multiple release names' do @@ -117,18 +117,30 @@ RSpec.describe Tooling::Helm3Client do it 'raises an error if the Helm command fails' do expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name.join(' ')})]) + .with([%(helm uninstall --namespace #{release_name[0]} #{release_name[0]})]) .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false))) expect { subject.delete(release_name: release_name) }.to raise_error(described_class::CommandFailedError) end - it 'calls helm uninstall with multiple release names' do - expect(Gitlab::Popen).to receive(:popen_with_detail) - .with([%(helm uninstall #{release_name.join(' ')})]) - .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + it 'calls helm uninstall with multiple release names and a namespace' do + release_name.each do |release| + expect(Gitlab::Popen).to receive(:popen_with_detail) + .with([%(helm uninstall --namespace namespace #{release})]) + .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + end + + subject.delete(release_name: release_name, namespace: 'namespace') + end + + it 'calls helm uninstall with multiple release names and no namespace' do + release_name.each do |release| + expect(Gitlab::Popen).to receive(:popen_with_detail) + .with([%(helm uninstall --namespace #{release} #{release})]) + .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true))) + end - expect(subject.delete(release_name: release_name)).to eq('') + subject.delete(release_name: release_name) end end end diff --git a/tooling/lib/tooling/helm3_client.rb b/tooling/lib/tooling/helm3_client.rb index d4e7faa802e..9059387351a 100644 --- a/tooling/lib/tooling/helm3_client.rb +++ b/tooling/lib/tooling/helm3_client.rb @@ -8,34 +8,32 @@ module Tooling class Helm3Client CommandFailedError = Class.new(StandardError) - attr_reader :namespace - RELEASE_JSON_ATTRIBUTES = %w[name revision updated status chart app_version namespace].freeze PAGINATION_SIZE = 256 # Default helm list pagination size - Release = Struct.new(:name, :revision, :last_update, :status, :chart, :app_version, :namespace) do + Release = Struct.new(:name, :namespace, :revision, :updated, :status, :chart, :app_version, keyword_init: true) do def revision @revision ||= self[:revision].to_i end def last_update - @last_update ||= self[:last_update] ? Time.parse(self[:last_update]) : nil + @last_update ||= self[:updated] ? Time.parse(self[:updated]) : nil end end # A single page of data and the corresponding page number. Page = Struct.new(:releases, :number) - def initialize(namespace:) - @namespace = namespace - end - def releases(args: []) each_release(args) end - def delete(release_name:) - run_command(['uninstall', release_name]) + def delete(release_name:, namespace: nil) + release_name = Array(release_name) + + release_name.each do |release| + run_command(['uninstall', '--namespace', (namespace || release), release]) + end end private @@ -66,7 +64,7 @@ module Tooling releases = JSON.parse(response) # rubocop:disable Gitlab/Json releases.map do |release| - Release.new(*release.values_at(*RELEASE_JSON_ATTRIBUTES)) + Release.new(release.slice(*RELEASE_JSON_ATTRIBUTES)) end rescue ::JSON::ParserError => ex puts "Ignoring this JSON parsing error: #{ex}\n\nResponse was:\n#{response}" # rubocop:disable Rails/Output |