Skip to content

Propagate group-level integrations

Arturo Herrero requested to merge propagate-group-level-integrations into master

What does this MR do?

In !40717 (merged) and !42128 (merged), we propagate instance-level integrations to groups.

This propagates group-level integrations to the lower levels using the same approach of batching and Sidekiq queues.

This is the backend behavior when saving an instance-level or group-level integration:

  • Update inherited integrations (find all integrations inheriting from the instance-level or group-level integration that we are updating).
  • For instance-level:
    • Create integration for all projects without integration
    • Create integration for all groups without integration
  • For group-level:
    • Create integration for projects belonging to the group without integration (new).
    • Create integration for groups belonging to the group without integration (new).

The creation of group-level integration is under a feature flag group_level_integrations.

SQL Queries

SELECT "projects".*
FROM "projects"
WHERE (NOT EXISTS
         (SELECT 1
          FROM "services"
          WHERE (services.project_id = projects.id)
            AND "services"."type" = 'JiraService'))
  AND "projects"."pending_delete" = FALSE
  AND "projects"."archived" = FALSE
  AND "projects"."namespace_id" IN
    (WITH RECURSIVE "base_and_descendants" AS (
                                                 (SELECT "namespaces".*
                                                  FROM "namespaces"
                                                  WHERE "namespaces"."type" = 'Group'
                                                    AND "namespaces"."id" = 3)
                                               UNION
                                                 (SELECT "namespaces".*
                                                  FROM "namespaces",
                                                       "base_and_descendants"
                                                  WHERE "namespaces"."type" = 'Group'
                                                    AND "namespaces"."parent_id" = "base_and_descendants"."id")) SELECT "namespaces"."id"
     FROM "base_and_descendants" AS "namespaces");
Time: 2.718 ms
  - planning: 2.290 ms
  - execution: 0.428 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 3 (~24.00 KiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Query plan: https://explain.depesz.com/s/H9GG


WITH RECURSIVE "base_and_descendants" AS (
                                            (SELECT "namespaces".*
                                             FROM "namespaces"
                                             WHERE "namespaces"."type" = 'Group'
                                               AND "namespaces"."parent_id" = 5)
                                          UNION
                                            (SELECT "namespaces".*
                                             FROM "namespaces",
                                                  "base_and_descendants"
                                             WHERE "namespaces"."type" = 'Group'
                                               AND "namespaces"."parent_id" = "base_and_descendants"."id"))
SELECT "namespaces".*
FROM "base_and_descendants" AS "namespaces"
WHERE (NOT EXISTS
         (SELECT 1
          FROM "services"
          WHERE (services.group_id = namespaces.id)
            AND "services"."type" = 'JiraService'));
Time: 1.421 ms
  - planning: 1.077 ms
  - execution: 0.344 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 4 (~32.00 KiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Query plan: https://explain.depesz.com/s/T3xX

Related to #209831 (closed)

Edited by Arturo Herrero

Merge request reports