Skip to content

GraphQL: Calculate CiRunner.upgradeStatus from aggregate of managers

What does this MR do and why?

GraphQL: Calculate CiRunner.upgradeStatus from aggregate of managers

This MR doesn't include a changelog trailer because CiRunner.upgradeStatus is still marked as alpha.

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. In rails console create a runner and some runner machines:

    runner_token = Ci::Runners::CreateRunnerService.new(user: User.find(1), params: {runner_type: 'instance_type'}).execute.payload[:runner].token
    runner = Ci::Runner.find_by_token(runner_token)
    
    # Create some managers under runner with different versions
    runner.ensure_manager('test1_system_id') { |m| m.version = '15.0.0' } # upgradeStatus should be RECOMMENDED
    runner.ensure_manager('test2_system_id') { |m| m.version = '16.1.0' } # upgradeStatus should be NOT_AVAILABLE
    
    # Ensure that the runner version's status is calculated
    runner.runner_managers.each { |m| Ci::Runners::ProcessRunnerVersionUpdateService.new(m.version).execute }
    
    # Note the global ID for the following step
    puts runner.to_global_id.uri
  2. Visit http://gdk.test:3000/-/graphql-explorer and run the following query:

    {
      runner(id: "gid://gitlab/Ci::Runner/9301") {
        id
        upgradeStatus
        managers {
          edges {
            node {
              id
              systemId
              version
              upgradeStatus
            }
          }
        }
      }
    }
  3. The runner upgradeStatus should show RECOMMENDED

  4. In the rails console, delete the runner machine which is listed as RECOMMENDED:

    runner.runner_managers.last.destroy!
  5. Refresh the GraphQL query - the runner upgradeStatus should show NOT_AVAILABLE.

  6. In the rails console, delete the last runner machine:

    runner.runner_managers.last.destroy!
  7. Refresh the GraphQL query - the runner upgradeStatus should show null.

MR acceptance checklist

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

Closes #411945 (closed)

Merge request reports