GraphQL: Add jobExecutionStatus to CiRunnerManager
What does this MR do and why?
This MR adds a jobExecutionStatus
field to the CiRunnerManager
type, in the same way that a homonymous field exists for the CiRunner
type.
Closes #415453 (closed)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Description | Screenshot |
---|---|
No jobs running | |
With jobs running |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Create an instance runner in http://gdk.test:3000/admin/runners with a specific tag, e.g.
mr-128275
-
Follow the instructions to register the runner with
gitlab-runner
on your local machine. -
Create a project and a
.gitlab-ci.yml
file inside it with the following contents:default: tags: - mr-128275 before_script: - echo "Before script section" - echo "For example you might run an update here or install a build dependency" - echo "Or perhaps you might print out some debugging details" after_script: - echo "After script section" - echo "For example you might do some cleanup here" build1: stage: build script: - echo "Do your build here" - sleep 30 test1: stage: test script: - echo "Do a test here" - echo "For example run a test suite" test2: stage: test script: - echo "Do another parallel test here" - echo "For example run a lint test" deploy1: stage: deploy script: - echo "Do your deploy here" environment: production
-
Run a pipeline, if it hasn't automatically run
-
Run the following query:
{ runner(id: "gid://gitlab/Ci::Runner/9214") { id managers { nodes { systemId jobExecutionStatus } } } }
The query should list a manager below the runner you created, and the jobExecutionStatus
should appear as either IDLE
or RUNNING
depending on whether the job is still running.
Database query plans
Ci::Runner Load /*line:/app/graphql/types/ci/runner_manager_type.rb:55:in `block in job_execution_status'*/
https://postgres.ai/console/gitlab/gitlab-production-ci/sessions/21125/commands/69260
SELECT "ci_runner_machines".*
FROM "ci_runner_machines"
WHERE "ci_runner_machines"."id" IN (5418412, 5306373, 513558, 310796, 387947, 511331, 515932, 323463, 4047403, 281676)
AND (EXISTS (
SELECT 1
FROM "ci_builds"
INNER JOIN "p_ci_runner_machine_builds" ON "p_ci_runner_machine_builds"."build_id" = "ci_builds"."id"
WHERE "ci_builds"."type" = 'Ci::Build'
AND ("ci_builds"."status" IN ('running'))
AND ("ci_builds".runner_id = "ci_runner_machines".runner_id)
AND ("p_ci_runner_machine_builds".runner_machine_id = "ci_runner_machines".id)
LIMIT 1))
Nested Loop Semi Join (cost=1.50..1365.71 rows=1 width=99) (actual time=0.196..0.483 rows=3 loops=1)
Buffers: shared hit=111
I/O Timings: read=0.000 write=0.000
-> Index Scan using ci_runner_machines_pkey on public.ci_runner_machines (cost=0.42..29.86 rows=10 width=99) (actual time=0.043..0.130 rows=9 loops=1)
Index Cond: (ci_runner_machines.id = ANY ('{5418412,5306373,513558,310796,387947,511331,515932,323463,4047403,281676}'::bigint[]))
Buffers: shared hit=39
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=1.07..133.58 rows=1 width=12) (actual time=0.038..0.038 rows=0 loops=9)
Buffers: shared hit=72
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_ci_builds_runner_id_running on public.ci_builds (cost=0.50..13.98 rows=9 width=12) (actual time=0.033..0.033 rows=0 loops=9)
Index Cond: (ci_builds.runner_id = ci_runner_machines.runner_id)
Buffers: shared hit=57
I/O Timings: read=0.000 write=0.000
-> Append (cost=0.57..13.18 rows=9 width=16) (actual time=0.014..0.014 rows=1 loops=3)
Buffers: shared hit=15
I/O Timings: read=0.000 write=0.000
-> Index Scan using ci_runner_machine_builds_100_pkey on gitlab_partitions_dynamic.ci_runner_machine_builds_100 (cost=0.57..3.24 rows=1 width=16) (actual time=0.013..0.013 rows=1 loops=3)
Index Cond: (ci_runner_machine_builds_100.build_id = ci_builds.id)
Buffers: shared hit=15
I/O Timings: read=0.000 write=0.000
-> Index Scan using ci_runner_machine_builds_101_pkey on gitlab_partitions_dynamic.ci_runner_machine_builds_101 (cost=0.15..9.89 rows=8 width=16) (actual time=0.000..0.000 rows=0 loops=0)
Index Cond: (ci_runner_machine_builds_101.build_id = ci_builds.id)
I/O Timings: read=0.000 write=0.000
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.