Create ci_runner_versions record on demand
What does this MR do and why?
Describe in detail what your merge request does and why.
This MR improves the experience of managing a CI runner fleet by updating the ci_runner_versions
table with the relevant entry whenever a runner is registered with a new version, or is upgraded to a new version. It kicks off a Sidekiq job to go and upsert the relevant ci_runner_versions
with the version and upgrade suggestion for that version. Normally this was done exclusively by the Ci::Runners::ReconcileExistingRunnerVersionsCronWorker
which currently runs hourly, but will be changed to run daily.
Closes Recalculate ci_runner_versions.status when requ... (#368702 - closed)
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Take note of the GitLab Runner registration token for your GDK instance at http://gdk.test:3000/admin/runners (under the
Register an instance runner
button), let's call it$YOUR_GDK_INSTANCE_TOKEN
-
Register a GitLab Runner against the GDK instance, e.g.:
gitlab-runner register -config /tmp/config.gdk.toml \ --executor "shell" \ --url "http://gdk.test:3000/" \ --description "Test runner" \ --tag-list "shell,mac,gdk,test" \ --run-untagged="false" \ --locked="false" \ --access-level="not_protected" \ --non-interactive \ --registration-token="$YOUR_GDK_INSTANCE_TOKEN"
-
In the GDK development log (
log/development.log
), you should see the service upserting the version for the runner you registered:Ci::RunnerVersion Upsert (0.5ms) INSERT INTO "ci_runner_versions" ("version","status") VALUES ('15.3.0~beta.31.g6f44ab4b', 1) ON CONFLICT ("version") DO UPDATE SET "status"=excluded."status" RETURNING "version" /*application:sidekiq,correlation_id:01G8X14HK42WR8QDY1C5GFST44,jid:a3d9470bf61ec5db265555be,endpoint_id:Ci::Runners::ProcessRunnerVersionUpdateWorker,db_config_name:ci,line:/app/services/ci/runners/process_runner_version_update_service.rb:14:in `execute'*/ ↳ app/services/ci/runners/process_runner_version_update_service.rb:14:in `execute'
-
In the GDK PostgreSQL console, we can see the record is now present:
SELECT * FROM ci_runner_versions WHERE version = '15.3.0~beta.31.g6f44ab4b' +--------------------------+--------+ | version | status | |--------------------------+--------| | 15.3.0~beta.31.g6f44ab4b | 1 | +--------------------------+--------+ SELECT 1
Database query plans
Upserting the version
https://postgres.ai/console/gitlab/gitlab-production-ci/sessions/11179/commands/39984
INSERT INTO "ci_runner_versions" ("version", "status")
VALUES ('15.3.0~beta.31.g6f44ab4b', 1)
ON CONFLICT ("version")
DO UPDATE SET
"status" = excluded."status"
RETURNING "version"
ModifyTable on public.ci_runner_versions (cost=0.00..0.01 rows=1 width=34) (actual time=26.315..26.319 rows=1 loops=1)
Buffers: shared hit=8 read=4 dirtied=2
I/O Timings: read=22.636 write=0.000
-> Result (cost=0.00..0.01 rows=1 width=34) (actual time=0.001..0.002 rows=1 loops=1)
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.