Skip to content

Return error message when there is unlinked security policy project

What does this MR do and why?

This MR adds new error message during the Security Policy creation to be returned when there is already Security Policy Project created, but it is unlinked.

Query plan

SELECT 1 AS one
FROM "projects"
WHERE "projects"."namespace_id" = 9970 AND "projects"."name" = 'gitlab' LIMIT 1;
Time: 15.251 ms  
  - planning: 5.859 ms  
  - execution: 9.392 ms  
    - I/O read: 9.230 ms  
    - I/O write: 0.000 ms  

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/25037/commands/79528

 Limit  (cost=0.56..3.58 rows=1 width=4) (actual time=9.310..9.312 rows=0 loops=1)
   Buffers: shared read=4
   I/O Timings: read=9.230 write=0.000
   ->  Index Only Scan using unique_projects_on_name_namespace_id on public.projects  (cost=0.56..3.58 rows=1 width=4) (actual time=9.307..9.308 rows=0 loops=1)
         Index Cond: ((projects.name = 'gitlab'::text) AND (projects.namespace_id = 9970))
         Heap Fetches: 0
         Buffers: shared read=4
         I/O Timings: read=9.230 write=0.000

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

Before After
image image

How to set up and validate locally

  1. Create new Group
  2. Create new Project
  3. Create new policy for the project - it will create new security policy project
  4. Go to Policies and unlink the security policy project
  5. Try to recreate the policy for that project

Related to #416875 (closed)

Edited by Alan (Maciej) Paruszewski

Merge request reports

Loading