Introduce worker to import finished builds to ClickHouse
What does this MR do and why?
This MR introduces a worker that leverages the service being introduced in !131902 (merged) to import finished builds to ClickHouse. This worker is only meant for GitLab.com for now (since customers won't have a ClickHouse installation), and is a GitLab Ultimate feature.
The worker is not marked as CPU-intensive, due to the ratio being below 30%:
EE: true
Closes Cron worker to ingest data from ci_builds to Cl... (#421201 - closed)
Screenshots
Sidekiq job executing:
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
NOTE: These steps were already tested in the upstream MR !132010 (merged), the only thing that this MR adds is the worker that will call the service
-
Go to the shell in your GDK
gitlab
directory and runbundle exec rake "gitlab:seed:runner_fleet"
. This will seed your GDK with some runners and jobs required for testing this MR. -
Enabled the FF:
Feature.enable(:ci_data_ingestion_to_click_house)
-
Create a new
Ci::FinishedBuildChSyncEvent
record for each finished build on the GDK console:Ci::Build.include EachBatch Ci::Build.finished.where.not(finished_at: nil).order(finished_at: :asc).each_batch(of: 5000) { |batch| batch = batch.map { |build| Ci::FinishedBuildChSyncEvent.new(build_id: build.id, build_finished_at: build.finished_at) }; Ci::FinishedBuildChSyncEvent.transaction { batch.each(&:save) } }
-
Invoke the service to import all the finished builds:
ClickHouse::CiFinishedBuildsSyncWorker.new.perform
-
The worker should import all the finished builds into the ClickHouse
ci_finished_builds
table.
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.