Skip to content

Api to list runners for a group

Aishwarya Subramanian requested to merge list-group-runners into master

What does this MR do?

This MR adds an api to fetch runners for a group.

Currently, there's an api to retrieve the runners for a project. The newly introduced api for groups follows similar pattern as that of the project in terms of filter params.

Query (without including parent runners):

SELECT
  "ci_runners".*
FROM
  "ci_runners"
  INNER JOIN "ci_runner_namespaces" ON "ci_runner_namespaces"."runner_id" = "ci_runners"."id"
WHERE
  "ci_runner_namespaces"."namespace_id" IN (
    SELECT
      "namespaces"."id"
    FROM
      "namespaces"
    WHERE
      "namespaces"."type" = 'Group'
      AND "namespaces"."id" = 675)

Query Plan: https://explain.depesz.com/s/iQqh

Execution time:

Time: 1.209 ms
  - planning: 1.084 ms
  - execution: 0.125 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 (including parent runners):

SELECT
  "ci_runners".*
FROM
  "ci_runners"
  INNER JOIN "ci_runner_namespaces" ON "ci_runner_namespaces"."runner_id" = "ci_runners"."id"
WHERE
  "ci_runner_namespaces"."namespace_id" IN ( WITH RECURSIVE "base_and_ancestors" AS (
(
        SELECT
          "namespaces".*
        FROM
          "namespaces"
        WHERE
          "namespaces"."type" = 'Group'
          AND "namespaces"."id" = 675)
      UNION (
        SELECT
          "namespaces".*
        FROM
          "namespaces",
          "base_and_ancestors"
        WHERE
          "namespaces"."type" = 'Group'
          AND "namespaces"."id" = "base_and_ancestors"."parent_id"))
    SELECT
      "namespaces"."id"
    FROM
      "base_and_ancestors" AS "namespaces")

Query Plan: https://explain.depesz.com/s/dhO3

Execution time:

Time: 9.383 ms
  - planning: 1.469 ms
  - execution: 7.914 ms
    - I/O read: 7.482 ms
    - I/O write: 0.000 ms

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

Query (with filter tags):

SELECT "ci_runners".* FROM "ci_runners" INNER JOIN "ci_runner_namespaces" ON "ci_runner_namespaces"."runner_id" = "ci_runners"."id" INNER JOIN "taggings" "ci::runner_taggings_ef68b39" ON "ci::runner_taggings_ef68b39"."taggable_id" = "ci_runners"."id" AND "ci::runner_taggings_ef68b39"."taggable_type" = 'Ci::Runner' AND "ci::runner_taggings_ef68b39"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE "tags"."name" ILIKE 'tag1' ESCAPE '!') INNER JOIN "taggings" "ci::runner_taggings_7d86d87" ON "ci::runner_taggings_7d86d87"."taggable_id" = "ci_runners"."id" AND "ci::runner_taggings_7d86d87"."taggable_type" = 'Ci::Runner' AND "ci::runner_taggings_7d86d87"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE "tags"."name" ILIKE 'tag2' ESCAPE '!') WHERE "ci_runner_namespaces"."namespace_id" IN (WITH RECURSIVE "base_and_ancestors" AS ((SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = 675)
UNION
(SELECT "namespaces".* FROM "namespaces", "base_and_ancestors" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = "base_and_ancestors"."parent_id")) SELECT "namespaces"."id" FROM "base_and_ancestors" AS "namespaces")

Query Plan: https://explain.depesz.com/s/V0dA

Execution time:

Time: 20.483 ms
  - planning: 11.455 ms
  - execution: 9.028 ms
    - I/O read: 8.379 ms
    - I/O write: 0.000 ms

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

Mentions: #30094 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Aishwarya Subramanian

Merge request reports