diff --git a/app/assets/javascripts/packages_and_registries/package_registry/components/details/version_row.vue b/app/assets/javascripts/packages_and_registries/package_registry/components/details/version_row.vue index 1afd1b69db0..57ff3cd2a83 100644 --- a/app/assets/javascripts/packages_and_registries/package_registry/components/details/version_row.vue +++ b/app/assets/javascripts/packages_and_registries/package_registry/components/details/version_row.vue @@ -61,11 +61,13 @@ export default { diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index d52129d73f3..98575c614e5 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -152,11 +152,13 @@ module Ci } scope :owned_or_instance_wide, -> (project_id) do + project = project_id.respond_to?(:shared_runners) ? project_id : Project.find(project_id) + from_union( [ belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), - instance_type + project.shared_runners ], remove_duplicates: false ) @@ -173,7 +175,7 @@ module Ci from_union( [ group_and_ancestor_runners, - instance_type + group.shared_runners ], remove_duplicates: false ) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 0dc20e0016c..92a33aacf3b 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -492,6 +492,10 @@ class Namespace < ApplicationRecord end end + def shared_runners + @shared_runners ||= shared_runners_enabled ? Ci::Runner.instance_type : Ci::Runner.none + end + def root? !has_parent? end diff --git a/data/deprecations/14-8-runner-api-project_type-breaking-change.yml b/data/deprecations/14-8-runner-api-project_type-breaking-change.yml new file mode 100644 index 00000000000..f3d899658c1 --- /dev/null +++ b/data/deprecations/14-8-runner-api-project_type-breaking-change.yml @@ -0,0 +1,15 @@ +- name: "REST API endpoint to list group runners no longer accepts `project_type` value for `type` argument" + announcement_milestone: "14.8" + announcement_date: "2022-02-22" + removal_milestone: "15.0" + removal_date: "2022-05-22" + breaking_change: true + reporter: pedropombeiro + body: | + The `GET /groups/:id/runners?type=project_type` endpoint will be removed in GitLab 15.0. The endpoint always returned an empty collection. + stage: Verify + tiers: [Core, Premium, Ultimate] + issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/351466 + documentation_url: https://docs.gitlab.com/ee/api/runners.html + image_url: # (optional) This is a link to a thumbnail image depicting the feature + video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 75ec02f344f..9ad28222804 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -11191,7 +11191,7 @@ four standard [pagination arguments](#connection-pagination-arguments): | `in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. | | `includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. | | `iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. | -| `search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. | +| `search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. Returns all iterations if empty. | | `sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. | | `startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. | | `state` | [`IterationState`](#iterationstate) | Filter iterations by state. | @@ -13935,7 +13935,7 @@ four standard [pagination arguments](#connection-pagination-arguments): | `in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. | | `includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. | | `iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. | -| `search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. | +| `search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. Returns all iterations if empty. | | `sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. | | `startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. | | `state` | [`IterationState`](#iterationstate) | Filter iterations by state. | diff --git a/doc/api/runners.md b/doc/api/runners.md index a8b98069719..c012c083c33 100644 --- a/doc/api/runners.md +++ b/doc/api/runners.md @@ -448,7 +448,7 @@ Example response: ## List project's runners -List all runners available in the project, including from ancestor groups and any shared runners. +List all runners available in the project, including from ancestor groups and [any allowed shared runners](../ci/runners/runners_scope.md#enable-shared-runners). ```plaintext GET /projects/:id/runners @@ -566,7 +566,7 @@ curl --request DELETE --header "PRIVATE-TOKEN: " "https://git ## List group's runners -List all runners available in the group as well as its ancestor groups, including any shared runners. +List all runners available in the group as well as its ancestor groups, including [any allowed shared runners](../ci/runners/runners_scope.md#enable-shared-runners). ```plaintext GET /groups/:id/runners @@ -576,13 +576,13 @@ GET /groups/:id/runners/all?paused=true GET /groups/:id/runners?tag_list=tag1,tag2 ``` -| Attribute | Type | Required | Description | -|------------|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `id` | integer | yes | The ID of the group owned by the authenticated user | -| `type` | string | no | The type of runners to show, one of: `instance_type`, `group_type`, `project_type` | -| `status` | string | no | The status of runners to show, one of: `online` and `offline`. `active` and `paused` are also possible values which were deprecated in GitLab 14.8 and will be removed in GitLab 15.0 | -| `paused` | boolean | no | Whether to include only runners that are accepting or ignoring new jobs | -| `tag_list` | string array | no | List of the runner's tags | +| Attribute | Type | Required | Description | +|------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | yes | The ID of the group owned by the authenticated user | +| `type` | string | no | The type of runners to show, one of: `instance_type`, `group_type`, `project_type`. The `project_type` value is [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/351466) and will be removed in GitLab 15.0 | +| `status` | string | no | The status of runners to show, one of: `online` and `offline`. `active` and `paused` are also possible values which were deprecated in GitLab 14.8 and will be removed in GitLab 15.0 | +| `paused` | boolean | no | Whether to include only runners that are accepting or ignoring new jobs | +| `tag_list` | string array | no | List of the runner's tags | ```shell curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/9/runners" diff --git a/doc/development/service_ping/metrics_dictionary.md b/doc/development/service_ping/metrics_dictionary.md index c70dac1381d..93eec4efabd 100644 --- a/doc/development/service_ping/metrics_dictionary.md +++ b/doc/development/service_ping/metrics_dictionary.md @@ -39,7 +39,7 @@ Each metric is defined in a separate YAML file consisting of a number of fields: | `product_group` | yes | The [group](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml) that owns the metric. | | `product_category` | no | The [product category](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/categories.yml) for the metric. | | `value_type` | yes | `string`; one of [`string`, `number`, `boolean`, `object`](https://json-schema.org/understanding-json-schema/reference/type.html). | -| `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `active`, `deprecated`, `removed`, `broken`. | +| `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `active`, `removed`, `broken`. | | `time_frame` | yes | `string`; may be set to a value like `7d`, `28d`, `all`, `none`. | | `data_source` | yes | `string`; may be set to a value like `database`, `redis`, `redis_hll`, `prometheus`, `system`. | | `data_category` | yes | `string`; [categories](#data-category) of the metric, may be set to `operational`, `optional`, `subscription`, `standard`. The default value is `optional`.| @@ -60,7 +60,6 @@ Metric definitions can have one of the following statuses: - `active`: Metric is used and reports data. - `broken`: Metric reports broken data (for example, -1 fallback), or does not report data at all. A metric marked as `broken` must also have the `repair_issue_url` attribute. -- `deprecated`: Metric is deprecated and possibly planned to be removed. - `removed`: Metric was removed, but it may appear in Service Ping payloads sent from instances running on older versions of GitLab. ### Metric value_type diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md index c897f45009d..d3ee30011db 100644 --- a/doc/update/deprecations.md +++ b/doc/update/deprecations.md @@ -777,6 +777,18 @@ When checking for active runners, specify `paused=false`. **Planned removal milestone: 15.0 (2022-05-22)** +### REST API endpoint to list group runners no longer accepts `project_type` value for `type` argument + +WARNING: +This feature will be changed or removed in 15.0 +as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes). +Before updating GitLab, review the details carefully to determine if you need to make any +changes to your code, settings, or workflow. + +The `GET /groups/:id/runners?type=project_type` endpoint will be removed in GitLab 15.0. The endpoint always returned an empty collection. + +**Planned removal milestone: 15.0 (2022-05-22)** + ### REST and GraphQL API Runner usage of `active` replaced by `paused` WARNING: diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 85934f61eef..a711247047e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -31854,6 +31854,9 @@ msgstr "" msgid "SecurityOrchestration|If you are using Auto DevOps, your %{monospacedStart}auto-deploy-values.yaml%{monospacedEnd} file will not be updated if you change a policy in this section. Auto DevOps users should make changes by following the %{linkStart}Container Network Policy documentation%{linkEnd}." msgstr "" +msgid "SecurityOrchestration|Invalid policy type" +msgstr "" + msgid "SecurityOrchestration|Latest scan" msgstr "" @@ -31872,6 +31875,12 @@ msgstr "" msgid "SecurityOrchestration|Policies" msgstr "" +msgid "SecurityOrchestration|Policy cannot be enabled for non-existing branches (%{branches})" +msgstr "" + +msgid "SecurityOrchestration|Policy cannot be enabled without branch information" +msgstr "" + msgid "SecurityOrchestration|Policy description" msgstr "" diff --git a/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/version_row_spec.js.snap b/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/version_row_spec.js.snap index 7aa42a1f1e5..bdd0fe3ad9e 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/version_row_spec.js.snap +++ b/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/version_row_spec.js.snap @@ -72,12 +72,14 @@ exports[`VersionRow renders 1`] = `
- Created - + + Created + +
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 275c9ef8f56..b076c1c7704 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -265,10 +265,10 @@ RSpec.describe Ci::Runner do it_behaves_like '.belonging_to_parent_group_of_project' end - context 'with existing system wide, group and project runners' do + context 'with instance runners sharing enabled' do # group specific - let_it_be(:group) { create(:group) } - let_it_be(:project) { create(:project, group: group) } + let_it_be(:group) { create(:group, shared_runners_enabled: true) } + let_it_be(:project) { create(:project, group: group, shared_runners_enabled: true) } let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group]) } # project specific @@ -299,6 +299,40 @@ RSpec.describe Ci::Runner do end end + context 'with instance runners sharing disabled' do + # group specific + let_it_be(:group) { create(:group, shared_runners_enabled: false) } + let_it_be(:project) { create(:project, group: group, shared_runners_enabled: false) } + let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group]) } + + # project specific + let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project]) } + + # globally shared + let_it_be(:shared_runner) { create(:ci_runner, :instance) } + + describe '.owned_or_instance_wide' do + subject { described_class.owned_or_instance_wide(project.id) } + + it 'returns a project specific and a group specific runner' do + is_expected.to contain_exactly(group_runner, project_runner) + end + end + + describe '.group_or_instance_wide' do + subject { described_class.group_or_instance_wide(group) } + + before do + # Ensure the project runner is instantiated + project_runner + end + + it 'returns a group specific runner' do + is_expected.to contain_exactly(group_runner) + end + end + end + describe '#display_name' do it 'returns the description if it has a value' do runner = build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448') diff --git a/spec/requests/api/ci/runners_spec.rb b/spec/requests/api/ci/runners_spec.rb index 4c2fb649e4d..8f4e9751f12 100644 --- a/spec/requests/api/ci/runners_spec.rb +++ b/spec/requests/api/ci/runners_spec.rb @@ -1048,6 +1048,7 @@ RSpec.describe API::Ci::Runners do ]) end + # TODO: Remove in %15.0 (https://gitlab.com/gitlab-org/gitlab/-/issues/351466) it 'returns empty result when type does not match' do get api("/groups/#{group.id}/runners?type=project_type", user) diff --git a/spec/support/shared_examples/loose_foreign_keys/have_loose_foreign_key.rb b/spec/support/shared_examples/loose_foreign_keys/have_loose_foreign_key.rb index 42eec74e64f..5f59d43ad19 100644 --- a/spec/support/shared_examples/loose_foreign_keys/have_loose_foreign_key.rb +++ b/spec/support/shared_examples/loose_foreign_keys/have_loose_foreign_key.rb @@ -7,6 +7,12 @@ RSpec.shared_examples 'it has loose foreign keys' do let(:fully_qualified_table_name) { "#{connection.current_schema}.#{table_name}" } let(:deleted_records) { LooseForeignKeys::DeletedRecord.where(fully_qualified_table_name: fully_qualified_table_name) } + around do |example| + LooseForeignKeys::DeletedRecord.using_connection(connection) do + example.run + end + end + it 'has at least one loose foreign key definition' do definitions = Gitlab::Database::LooseForeignKeys.definitions_by_table[table_name] expect(definitions.size).to be > 0 @@ -69,7 +75,9 @@ RSpec.shared_examples 'cleanup by a loose foreign key' do expect(find_model).to be_present - LooseForeignKeys::ProcessDeletedRecordsService.new(connection: model.connection).execute + LooseForeignKeys::DeletedRecord.using_connection(parent.connection) do + LooseForeignKeys::ProcessDeletedRecordsService.new(connection: parent.connection).execute + end if foreign_key_definition.on_delete.eql?(:async_delete) expect(find_model).not_to be_present