Skip to content

Add support for filtering by group in runner usage queries

This MR is based on the pedropombeiro/440605/1-refactor-service-classes branch, please change to master before merging

What does this MR do and why?

Add support for filtering by group in runner usage queries

  • Changelog: added
  • EE: true

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.

image

How to set up and validate locally

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

  1. Ensure you have an Ultimate license associated with your GDK

  2. Follow https://docs.gitlab.com/ee/development/database/clickhouse/clickhouse_within_gitlab.html#gdk-setup up to and including running migrations

  3. 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.

  4. Run the following in the rails console:

    ::Ci::Build.where.not(finished_at: nil).order(id: :desc).limit(5000).each{|build| ::Ci::FinishedBuildChSyncEvent.upsert({ build_id: build.id, build_finished_at: build.finished_at }, unique_by: [:build_id, :partition]) }
    ClickHouse::DataIngestion::CiFinishedBuildsSyncService.new.execute
  5. visit -/graphql-explorer execute the following graphql query, replacing the fullPathD with the value returned by Ci::Runner.group_type.last.groups.first.full_path:

    {
      runnerUsageByProject(
        fullPath: "rf-top-level-group-1"
        fromDate: "2023-01-01"
        toDate: "2023-12-31"
        projectsLimit: 10
      ) {
        project {
          id
          fullPath
        }
        ciBuildCount
        ciMinutesUsed
      }
    }

You should get something like:

{
  "data": {
    "runnerUsageByProject": [
      {
        "project": {
          "id": "gid://gitlab/Project/20",
          "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1"
        },
        "ciBuildCount": "958440",
        "ciMinutesUsed": "521908396"
      },
      {
        "project": {
          "id": "gid://gitlab/Project/21",
          "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.2/rf-project-1-1-2-1"
        },
        "ciBuildCount": "27231",
        "ciMinutesUsed": "14222261"
      }
    ]
  }
}
Edited by Pedro Pombeiro

Merge request reports