Propagate integration to group descendants
What does this MR do?
After propagating group-level integrations !44023 (merged), we missed one scenario where the integration could inherit from another integration from the ancestors, not the closest one, this is something that we also fixed finding the closest integration !45022 (merged).
Example: Having a group, a subgroup, and a project belonging to the
subgroup. If we update the group, it propagates the settings to the
subgroup and project (both having inherit_from_id = group.id
(pointing
to the group) but if after that, we update the settings of the subgroup,
it doesn't propagate them to the project. This is because the project's
inherit_from_id
is still pointing to the group id from the first
propagation.
This always updates the integrations of any descendants for a group integration.
Group-level integrations are under group_level_integrations
feature flag, not changelog is needed.
SQL Queries
SELECT "services"."id"
FROM (
(SELECT "services".*
FROM "services"
WHERE "services"."type" = 'JiraService'
AND "services"."inherit_from_id" IN
(SELECT "services"."id"
FROM "services"
WHERE "services"."type" = 'JiraService'
AND ("services"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."id" = 3)
OR "services"."instance" = TRUE))
AND "services"."group_id" IN
(WITH RECURSIVE "base_and_descendants" AS (
(SELECT "namespaces".*
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."parent_id" = 3)
UNION
(SELECT "namespaces".*
FROM "namespaces",
"base_and_descendants"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."parent_id" = "base_and_descendants"."id")) SELECT id
FROM "base_and_descendants" AS "namespaces"))
UNION
(SELECT "services".*
FROM "services"
WHERE "services"."type" = 'JiraService'
AND "services"."inherit_from_id" IN
(SELECT "services"."id"
FROM "services"
WHERE "services"."type" = 'JiraService'
AND ("services"."group_id" IN
(SELECT "namespaces"."id"
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."id" = 3)
OR "services"."instance" = TRUE))
AND "services"."project_id" IN
(SELECT "projects"."id"
FROM "projects"
WHERE "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")))) services
ORDER BY "services"."id" ASC
LIMIT 10000;
Time: 4.465 ms
- planning: 3.564 ms
- execution: 0.901 ms
Query Plan: https://explain.depesz.com/s/swcF
Related to #209831 (closed) and #268258 (closed).