Skip to content

GraphQL: Add CiRunnerMachine type

What does this MR do and why?

Describe in detail what your merge request does and why.

NOTE: This MR is probably best reviewed commit by commit, as I've tried to isolate each concern into its own commit.

This MR adds:

  • a CiRunnerMachine type to represent the ci_runner_machines table;
  • the policy for Ci::RunnerMachine;
  • a machines field in the CiRunner type.

It also makes a minor change in the computation of the stale state for Ci::Runner for consistency with Ci::RunnerMachine, meaning that if the runner was not seen it 3 months or more, then it is considered stale. Until now, if the runner had been seen exactly 3 months ago, it would still not be considered stale. This has no practical implications in the software, but better be coherent across similar models.

Closes #395013 (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. We'll first need to enable a couple of FFs in rails console:

    Feature.enable(:create_runner_workflow_for_admin)
    Feature.enable(:create_runner_machine)
  2. We'll then need to create a new runner (you'll need the value from the ephemeralAuthenticationToken field in the following step):

    Open http://gdk.test:3000/-/graphql-explorer and enter the following mutation:

    mutation runnerCreate($input: RunnerCreateInput!) {
      runnerCreate(input: $input) {
        runner {
          id
          ephemeralAuthenticationToken
          contactedAt
        }
        errors
      }
    }

    with the following variables:

    {
      "input": {
        "description": "my awesome description",
        "maintenanceNote": "often.",
        "paused": true
      }
    }
  3. We can now "register" a runner machine under the runner we just created:

    curl --request POST "http://gdk.test:3000/api/v4/runners/verify" --form "token=$EPHEMERAL_RUNNER_TOKEN" --form "system_id=s_some_system_id"
  4. Finally, we can test this MR by listing the runner machines under the runner we created:

    {
      runners(sort: CREATED_ASC, last: 1) {
        nodes {
          id
          tagList
          machines {
            nodes {
              id
              createdAt
              contactedAt
              version
              revision
              status
              platformName
              architectureName
              executorName
              ipAddress
            }
          }
        }
      }
    }

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