Commit 7b1cb784 authored by Stan Hu's avatar Stan Hu

Merge branch 'pedropombeiro/345361/graphql-expose-runner-executor' into 'master'

GraphQL: Expose executor field in CiRunner

See merge request gitlab-org/gitlab!76534
parents aaead3d2 9bd1a642
...@@ -54,6 +54,10 @@ module Types ...@@ -54,6 +54,10 @@ module Types
description: "Number of jobs processed by the runner (limited to #{JOB_COUNT_LIMIT}, plus one to indicate that more items exist)." description: "Number of jobs processed by the runner (limited to #{JOB_COUNT_LIMIT}, plus one to indicate that more items exist)."
field :admin_url, GraphQL::Types::String, null: true, field :admin_url, GraphQL::Types::String, null: true,
description: 'Admin URL of the runner. Only available for administrators.' description: 'Admin URL of the runner. Only available for administrators.'
field :executor_name, GraphQL::Types::String, null: true,
description: 'Executor last advertised by the runner.',
method: :executor_name,
feature_flag: :graphql_ci_runner_executor
def job_count def job_count
# We limit to 1 above the JOB_COUNT_LIMIT to indicate that more items exist after JOB_COUNT_LIMIT # We limit to 1 above the JOB_COUNT_LIMIT to indicate that more items exist after JOB_COUNT_LIMIT
......
...@@ -441,6 +441,7 @@ module Ci ...@@ -441,6 +441,7 @@ module Ci
private private
EXECUTOR_NAME_TO_TYPES = { EXECUTOR_NAME_TO_TYPES = {
'unknown' => :unknown,
'custom' => :custom, 'custom' => :custom,
'shell' => :shell, 'shell' => :shell,
'docker' => :docker, 'docker' => :docker,
...@@ -454,6 +455,8 @@ module Ci ...@@ -454,6 +455,8 @@ module Ci
'kubernetes' => :kubernetes 'kubernetes' => :kubernetes
}.freeze }.freeze
EXECUTOR_TYPE_TO_NAMES = EXECUTOR_NAME_TO_TYPES.invert.freeze
def cleanup_runner_queue def cleanup_runner_queue
Gitlab::Redis::SharedState.with do |redis| Gitlab::Redis::SharedState.with do |redis|
redis.del(runner_queue_key) redis.del(runner_queue_key)
......
...@@ -11,5 +11,9 @@ module Ci ...@@ -11,5 +11,9 @@ module Ci
delegator_override :locked delegator_override :locked
alias_method :locked, :locked? alias_method :locked, :locked?
def executor_name
Ci::Runner::EXECUTOR_TYPE_TO_NAMES[executor_type&.to_sym]
end
end end
end end
---
name: graphql_ci_runner_executor
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76534
rollout_issue_url:
milestone: '14.7'
type: development
group: group::runner
default_enabled: false
...@@ -8888,6 +8888,7 @@ Represents the total number of issues and their weights for a particular day. ...@@ -8888,6 +8888,7 @@ Represents the total number of issues and their weights for a particular day.
| <a id="cirunneradminurl"></a>`adminUrl` | [`String`](#string) | Admin URL of the runner. Only available for administrators. | | <a id="cirunneradminurl"></a>`adminUrl` | [`String`](#string) | Admin URL of the runner. Only available for administrators. |
| <a id="cirunnercontactedat"></a>`contactedAt` | [`Time`](#time) | Last contact from the runner. | | <a id="cirunnercontactedat"></a>`contactedAt` | [`Time`](#time) | Last contact from the runner. |
| <a id="cirunnerdescription"></a>`description` | [`String`](#string) | Description of the runner. | | <a id="cirunnerdescription"></a>`description` | [`String`](#string) | Description of the runner. |
| <a id="cirunnerexecutorname"></a>`executorName` | [`String`](#string) | Executor last advertised by the runner. Available only when feature flag `graphql_ci_runner_executor` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. |
| <a id="cirunnerid"></a>`id` | [`CiRunnerID!`](#cirunnerid) | ID of the runner. | | <a id="cirunnerid"></a>`id` | [`CiRunnerID!`](#cirunnerid) | ID of the runner. |
| <a id="cirunneripaddress"></a>`ipAddress` | [`String`](#string) | IP address of the runner. | | <a id="cirunneripaddress"></a>`ipAddress` | [`String`](#string) | IP address of the runner. |
| <a id="cirunnerjobcount"></a>`jobCount` | [`Int`](#int) | Number of jobs processed by the runner (limited to 1000, plus one to indicate that more items exist). | | <a id="cirunnerjobcount"></a>`jobCount` | [`Int`](#int) | Number of jobs processed by the runner (limited to 1000, plus one to indicate that more items exist). |
...@@ -11,7 +11,7 @@ RSpec.describe GitlabSchema.types['CiRunner'] do ...@@ -11,7 +11,7 @@ RSpec.describe GitlabSchema.types['CiRunner'] do
expected_fields = %w[ expected_fields = %w[
id description contacted_at maximum_timeout access_level active status id description contacted_at maximum_timeout access_level active status
version short_sha revision locked run_untagged ip_address runner_type tag_list version short_sha revision locked run_untagged ip_address runner_type tag_list
project_count job_count admin_url user_permissions project_count job_count admin_url user_permissions executor_name
] ]
expect(described_class).to include_graphql_fields(*expected_fields) expect(described_class).to include_graphql_fields(*expected_fields)
......
...@@ -11,7 +11,7 @@ RSpec.describe 'Query.runner(id)' do ...@@ -11,7 +11,7 @@ RSpec.describe 'Query.runner(id)' do
let_it_be(:active_instance_runner) do let_it_be(:active_instance_runner) do
create(:ci_runner, :instance, description: 'Runner 1', contacted_at: 2.hours.ago, create(:ci_runner, :instance, description: 'Runner 1', contacted_at: 2.hours.ago,
active: true, version: 'adfe156', revision: 'a', locked: true, ip_address: '127.0.0.1', maximum_timeout: 600, active: true, version: 'adfe156', revision: 'a', locked: true, ip_address: '127.0.0.1', maximum_timeout: 600,
access_level: 0, tag_list: %w[tag1 tag2], run_untagged: true) access_level: 0, tag_list: %w[tag1 tag2], run_untagged: true, executor_type: :custom)
end end
let_it_be(:inactive_instance_runner) do let_it_be(:inactive_instance_runner) do
...@@ -22,7 +22,7 @@ RSpec.describe 'Query.runner(id)' do ...@@ -22,7 +22,7 @@ RSpec.describe 'Query.runner(id)' do
let_it_be(:active_group_runner) do let_it_be(:active_group_runner) do
create(:ci_runner, :group, groups: [group], description: 'Group runner 1', contacted_at: 2.hours.ago, create(:ci_runner, :group, groups: [group], description: 'Group runner 1', contacted_at: 2.hours.ago,
active: true, version: 'adfe156', revision: 'a', locked: true, ip_address: '127.0.0.1', maximum_timeout: 600, active: true, version: 'adfe156', revision: 'a', locked: true, ip_address: '127.0.0.1', maximum_timeout: 600,
access_level: 0, tag_list: %w[tag1 tag2], run_untagged: true) access_level: 0, tag_list: %w[tag1 tag2], run_untagged: true, executor_type: :shell)
end end
def get_runner(id) def get_runner(id)
...@@ -69,6 +69,7 @@ RSpec.describe 'Query.runner(id)' do ...@@ -69,6 +69,7 @@ RSpec.describe 'Query.runner(id)' do
'runUntagged' => runner.run_untagged, 'runUntagged' => runner.run_untagged,
'ipAddress' => runner.ip_address, 'ipAddress' => runner.ip_address,
'runnerType' => runner.instance_type? ? 'INSTANCE_TYPE' : 'PROJECT_TYPE', 'runnerType' => runner.instance_type? ? 'INSTANCE_TYPE' : 'PROJECT_TYPE',
'executorName' => runner.executor_type&.dasherize,
'jobCount' => 0, 'jobCount' => 0,
'projectCount' => nil, 'projectCount' => nil,
'adminUrl' => "http://localhost/admin/runners/#{runner.id}", 'adminUrl' => "http://localhost/admin/runners/#{runner.id}",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment