Fix allow_descendants_override_disabled_shared_runners in database
What does this MR do and why?
Fix allow_descendants_override_disabled_shared_runners in database
In !126539 (merged) we introduced the validation on allow_descendants_override_disabled_shared_runners to always be false if shared runners are enabled.
It's guarded by
changes.has_key?(:allow_descendants_override_disabled_shared_runners)
but it can break the creation of new groups https://gitlab.com/gitlab-org/gitlab/blob/49d501d43ca347e7300a7097db1802b9522bf7cb/app/services/groups/create_service.rb#L105-105 because it can copy invalid configuration from the parent group:
@group.shared_runners_enabled = @group.parent.shared_runners_enabled
@group.allow_descendants_override_disabled_shared_runners = @group.parent.allow_descendants_override_disabled_shared_runners
This MR fixes the invalid combination of
-
shared_runners_enabled = TRUE
AND allow_descendants_override_disabled_shared_runners = TRUE
This combination doesn't make sense: we always allow to disable shared runners on the descendants.
Changelog: fixed
Migration logs
./bin/rails db:migrate
main: == [advisory_lock_connection] object_id: 224940, pg_backend_pid: 90144
main: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: migrating
main: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: migrated (0.0726s)
main: == [advisory_lock_connection] object_id: 224940, pg_backend_pid: 90144
ci: == [advisory_lock_connection] object_id: 225340, pg_backend_pid: 90150
ci: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: migrating
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_internal, :gitlab_shared].
ci: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: migrated (0.0080s)
ci: == [advisory_lock_connection] object_id: 225340, pg_backend_pid: 90150
main: == [advisory_lock_connection] object_id: 224560, pg_backend_pid: 91436
main: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: reverting
main: == 20230802085923 QueueFixAllowDescendantsOverrideDisabledSharedRunners: reverted (0.0349s)
main: == [advisory_lock_connection] object_id: 224560, pg_backend_pid: 91436
Execution plan
explain UPDATE "namespaces" SET "allow_descendants_override_disabled_shared_runners" = FALSE WHERE "namespaces"."id" BETWEEN 1000000 AND 1001000 AND "namespaces"."shared_runners_enabled" = TRUE AND "namespaces"."allow_descendants_override_disabled_shared_runners" = TRUE AND "namespaces"."id" >= 1000000
ModifyTable on public.namespaces (cost=0.56..592.62 rows=1 width=410) (actual time=496.854..496.856 rows=0 loops=1)
Buffers: shared hit=212 read=229 dirtied=9
I/O Timings: read=489.084 write=0.000
-> Index Scan using namespaces_pkey on public.namespaces (cost=0.56..592.62 rows=1 width=410) (actual time=496.851..496.851 rows=0 loops=1)
Index Cond: ((namespaces.id >= 1000000) AND (namespaces.id <= 1001000) AND (namespaces.id >= 1000000))
Filter: (namespaces.shared_runners_enabled AND namespaces.allow_descendants_override_disabled_shared_runners)
Rows Removed by Filter: 924
Buffers: shared hit=212 read=229 dirtied=9
I/O Timings: read=489.084 write=0.000
From https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/21035/commands/68766
Related issues
https://gitlab.com/gitlab-org/gitlab/-/issues/419842+
How to set up and validate locally
I relied on tests for this one
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.