Adding services to autopopulate and clear autopopulated allowlist entries
What does this MR do and why?
Following on the changes in Ci::JobToken::AuthorizationsCompactor (!172152 - merged) and as detailed in #478540 (comment 2241812875), this MR adds two services:
- Auto-populates the allowlist entries for a given project from the Authorizations log
- Deletes all auto-populated entries for a given project
Database Review
Ci::JobToken::GroupScopeLink.create! is used in the context of creating new entries, and produces this query and plan:
INSERT INTO
"ci_job_token_group_scope_links" (
"source_project_id",
"target_group_id",
"created_at",
"autopopulated"
)
VALUES
(37, 22, '2024-12-12 16:42:35.346468', TRUE) RETURNING "id"
Insert on ci_job_token_group_scope_links (cost=0.00..0.01 rows=1 width=74)
-> Result (cost=0.00..0.01 rows=1 width=74)
Ci::JobToken::ProjectScopeLink.create! is used in the context of creating new entries, and produces this query and plan:
INSERT INTO
"ci_job_token_project_scope_links" (
"source_project_id",
"target_project_id",
"created_at",
"direction",
"autopopulated"
)
VALUES
(1, 37, '2024-12-12 16:44:22.594892', 1, TRUE) RETURNING "id"
Insert on ci_job_token_project_scope_links (cost=0.00..0.01 rows=1 width=76)
-> Result (cost=0.00..0.01 rows=1 width=76)
Ci::JobToken::GroupScopeLink.autopopulated is used in the context of deletion, and produces this query and plan:
DELETE FROM
"ci_job_token_group_scope_links"
WHERE
"ci_job_token_group_scope_links"."autopopulated" = TRUE
AND "ci_job_token_group_scope_links"."source_project_id" = 999
Delete on ci_job_token_group_scope_links (cost=0.00..0.00 rows=0 width=0)
-> Seq Scan on ci_job_token_group_scope_links (cost=0.00..0.00 rows=1 width=6)
Filter: (autopopulated AND (source_project_id = 999))
Ci::JobToken::ProjectScopeLink.autopopulated is used in the context of deletion, and produces this query and plan:
DELETE FROM
"ci_job_token_project_scope_links"
WHERE
"ci_job_token_project_scope_links"."autopopulated" = TRUE
AND "ci_job_token_project_scope_links"."source_project_id" = 999
Delete on ci_job_token_project_scope_links (cost=0.00..0.00 rows=0 width=0)
-> Seq Scan on ci_job_token_project_scope_links (cost=0.00..0.00 rows=1 width=6)
Filter: (autopopulated AND (source_project_id = 999))
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.