Skip to content

GraphQL: Add runnerMachine field to CiJob type

What does this MR do and why?

Describe in detail what your merge request does and why.

This MR is best reviewed commit-by-commit, as it touches 3 related areas:

  • Adds a systemId field to CiRunnerMachine;
  • Adds a Preloaders::RunnerMachinePolicyPreloader to do the necessary preloading for the Ci::RunnerPolicy class;
  • Adds a runnerMachine field to CiJob (which relies on the preloader to avoid N+1 queries).

There is no changelog trailer since the new fields are marked as alpha.

Closes #395783 (closed)

Screenshots or screen recordings

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

image

How to set up and validate locally

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

  1. Go to the shell in your GDK gitlab directory and run bundle exec rake "gitlab:seed:runner_fleet". This will seed your GDK with some runners and jobs required for testing this MR.

  2. Open the GDK console (rails console in a shell), and run the following commands, taking note of the GraphQL GID at the end:

    > runner = Ci::Runner.instance_type.first
    > runner.builds.first.update!(runner_machine: Ci::RunnerMachine.new(runner: runner, system_xid: "s_test_id1"))
    > runner.builds.second.update!(runner_machine: Ci::RunnerMachine.new(runner: runner, system_xid: "s_test_id2"))
    > runner.to_global_id.to_s
    => "gid://gitlab/Ci::Runner/1"
  3. Open http://gdk.test:3000/-/graphql-explorer

    {
      runner(id: "gid://gitlab/Ci::Runner/1") {
        jobs(last: 5) {
          nodes {
            id
            name
            runnerMachine {
              architectureName
              contactedAt
              createdAt
              executorName
              id
              ipAddress
              platformName
              revision
              status
              systemId
              version
            }
          }
        }
      }
    }

The runner should list the 2 runner machines that were just created (one in each of the 2 jobs, the remaining being null values).

The application log should show that the 5 runners and 2 runner machines are fetched in one go, instead of one request per record:

image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Pedro Pombeiro

Merge request reports

Loading