Skip to content

GraphQL: Add fullPath argument in runnerUsage query

What does this MR do and why?

Add support for filtering by group/project in runner usage queries

  • Changelog: added
  • EE: true

Closes #463079 (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.

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 fullPath value with the value returned by Ci::Runner.group_type.last.groups.first.full_path:

    {
      runnerUsage(
        fullPath: "rf-top-level-group-1"
        fromDate: "2023-01-01"
        toDate: "2023-12-31"
        runnersLimit: 10
      ) {
        runner {
          id
          runnerType
          groups {
            nodes {
              fullPath
            }
          }
          projects {
            nodes {
              fullPath
            }
          }
        }
        ciBuildCount
        ciMinutesUsed
      }
    }

You should get something like:

{
  "data": {
    "runnerUsage": [
      {
        "runner": {
          "id": "gid://gitlab/Ci::Runner/7",
          "runnerType": "PROJECT_TYPE",
          "groups": null,
          "projects": {
            "nodes": [
              {
                "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1"
              }
            ]
          }
        },
        "ciBuildCount": "7998",
        "ciMinutesUsed": "4992661"
      },
      {
        "runner": {
          "id": "gid://gitlab/Ci::Runner/23",
          "runnerType": "PROJECT_TYPE",
          "groups": null,
          "projects": {
            "nodes": [
              {
                "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1"
              }
            ]
          }
        },
        "ciBuildCount": "7996",
        "ciMinutesUsed": "4792587"
      },
      {
        "runner": {
          "id": "gid://gitlab/Ci::Runner/2",
          "runnerType": "PROJECT_TYPE",
          "groups": null,
          "projects": {
            "nodes": [
              {
                "fullPath": "rf2-top-level-group-1/rf2-group-1.1/rf2-group-1.1.1/rf2-project-1-1-1-1"
              },
              {
                "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.2/rf-project-1-1-2-1"
              },
              {
                "fullPath": "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1"
              }
            ]
          }
        }
      }
    ]
  }
}
Edited by Pedro Pombeiro

Merge request reports