Skip to content

GraphQL: Expose associatedProjects in mutation

What does this MR do and why?

Describe in detail what your merge request does and why.

This MR exposes an associatedProjects argument in the runnerUpdate GraphQL mutation, allowing the list of associated projects (ci_runner_projects table) of a runner to be set in one go.

Nomenclature:

name meaning
ownerProject The first project that the runner registered with. This is immutable.
associatedProjects The subsequent projects that the runner was associated with. Can be zero or more projects.
projects The set comprised of ownerProject + associatedProjects

Part of GraphQL API: Extend `runnerUpdate` mutation to ... (#359958 - closed)

Screenshots or screen recordings

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

situation screenshot
mutation (update runner 1 to be associated with projects 1 and 20)
generated audit event image
  • GraphQL query to find projects associated with a runner:

    {
      runners(type:PROJECT_TYPE) {
        nodes {
          id
          projects {
            nodes {
              id
              path
            }
          }
        }
      }
    }

How to set up and validate locally

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

  1. Open the Runners section http://gdk.test:3000/gitlab-org/gitlab-shell/-/settings/ci_cd

  2. Register a CI runner using the token listed in the Specific runners section

    gitlab-runner register -config ~/.gitlab-runner/config.gdk.toml \
            --executor "shell" \
            --url "http://gdk.test:3000/" \
            --description "Project test runner" \
            --tag-list "shell,gdk,test" \
            --run-untagged="false" \
            --locked="false" \
            --access-level="not_protected" \
            --non-interactive \
            --registration-token="$REGISTRATION_TOKEN"
  3. Open another project, e.g. http://gdk.test:3000/flightjs/Flight, and make note of the project ID:

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

    mutation runnerUpdate($input: RunnerUpdateInput!) {
      runnerUpdate(input: $input) {
        runner {
          id
          ownerProject {
            id
          }
          projects {
            nodes {
              id
            }
          }
        }
        errors
      }
    }
  5. In the Query variables section, enter the following JSON and adapt the IDs with ones adapted to your scenario:

    {
      "input": {
        "id": "gid://gitlab/Ci::Runner/1",
        "associatedProjects": [
          "gid://gitlab/Project/1",
          "gid://gitlab/Project/20"
        ]
      }
    }
  6. Press Play to change the projects associated with the runner and ensure that the resulting runner on the right pane makes sense.

  7. Visit http://gdk.test:3000/admin/audit_logs and ensure there is an entry for each mutation executed.

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