Skip to content

Capture running builds on non-shared runners

What does this MR do and why?

This MR expands the usage of Ci::RunningBuild.upsert_shared_runner_build! to capture all running builds, not only the ones running on shared runners. This will be needed for #437849 (closed).

I've added a FF to derisk .com deployment. Once we confirm that no adverse effects occurred from creating/destroying the additional Ci::RunningBuild instances, we can remove this FF (patch in rollout issue).

Looking at the production database, we're creating 1.1M records on a typical day. With this change, that will increase to almost 5M.

Changelog: changed

Closes #437846 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

n/a

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

The tests already cover the changes performed. However, this can be tested by following the steps below:

  1. Enable the FF in the GDK Rails console:

    Feature.enable(:add_all_ci_running_builds)
    Feature.enable(:remove_all_ci_running_builds)
  2. Select a project in your GDK.

  3. Create and register a project runner in that project with the tags: shell, gdk.

  4. Edit the .gitlab-ci.yml to include the following content:

    default:
      tags:
        - shell
        - gdk
    
    build1:
      stage: build
      script:
        - echo "Do your build here"
        - sleep 300
  5. Commit and ensure a pipeline is run.

  6. On the GDK Rails console, confirm that the Ci::RunningBuild was created:

    > Ci::RunningBuild.where.not(runner_type: :instance_type).exists?
      Ci::RunningBuild Exists? (0.4ms)  SELECT 1 AS one FROM "ci_running_builds" WHERE "ci_running_builds"."runner_type" != 1 LIMIT 1 /*application:console,db_config_name:ci,console_hostname:gitlab-macbookpro.work.pombei.ro,console_username:pedropombeiro,line:(pry):12:in `__pry__'*/
    => true

Merge request reports