Commit 7c5173b6 authored by Miguel Rincon's avatar Miguel Rincon

Runner status won't return "paused"

This change removes a data duplication in the GraphQL API by removing
the `PAUSED` status as a possible result of the Ci::Runner `status`

The same change is announced for the REST API for "status", and "paused"
will be removed in the next major release.

In both cases, when checking if a runner is "paused", API users are
advised to check the boolean attribute "active" to be `false` instead.

Changelog: changed
parent 57fea91f
......@@ -6,27 +6,30 @@ module Ci
def runner_status_icon(runner, size: 16, icon_class: '')
status = runner.status
active = runner.active
title = ''
icon = 'warning-solid'
span_class = ''
case status
when :online
if active
title = s_("Runners|Runner is online, last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(runner.contacted_at) }
icon = 'status-active'
span_class = 'gl-text-green-500'
else
title = s_("Runners|Runner is paused, last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(runner.contacted_at) }
icon = 'status-paused'
span_class = 'gl-text-gray-600'
end
when :not_connected
title = s_("Runners|New runner, has not connected yet")
icon = 'warning-solid'
when :online
title = s_("Runners|Runner is online, last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(runner.contacted_at) }
icon = 'status-active'
span_class = 'gl-text-green-500'
when :offline
title = s_("Runners|Runner is offline, last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(runner.contacted_at) }
icon = 'status-failed'
span_class = 'gl-text-red-500'
when :paused
title = s_("Runners|Runner is paused, last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(runner.contacted_at) }
icon = 'status-paused'
span_class = 'gl-text-gray-600'
end
content_tag(:span, class: span_class, title: title, data: { toggle: 'tooltip', container: 'body', testid: 'runner_status_icon', qa_selector: "runner_status_#{status}_content" }) do
......
......@@ -274,6 +274,14 @@ module Ci
end
def status
return :not_connected unless contacted_at
online? ? :online : :offline
end
# DEPRECATED
# TODO Remove in %15.0 in favor of `status` for REST calls, see https://gitlab.com/gitlab-org/gitlab/-/issues/344648
def deprecated_rest_status
if contacted_at.nil?
:not_connected
elsif active?
......
- name: "REST API Runner will not contain 'paused'"
announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated.
removal_milestone: "15.0" # the milestone when this feature is planned to be removed
body: | # Do not modify this line, instead modify the lines below.
Runner REST API will not return "paused" as a status in GitLab 15.0.
REST API: Paused runners' status will only relate to runner contact status, such as:
"online", "offline", "not_connected". Status "paused" will not appear when the runner is
not active.
When checking if a runner is "paused", API users are advised to check the boolean attribute
"active" to be `false` instead.
stage: Verify
tiers: [Core, Premium, Ultimate]
issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344648
documentation_url: https://docs.gitlab.com/ee/api/runners.html
......@@ -12,7 +12,9 @@ module API
expose :runner_type
expose :name
expose :online?, as: :online
expose :status
# DEPRECATED
# TODO Remove in %15.0 in favor of `status` for REST calls, see https://gitlab.com/gitlab-org/gitlab/-/issues/344648
expose :status, as: :deprecated_rest_status
end
end
end
......
......@@ -626,7 +626,7 @@ RSpec.describe Ci::Runner do
end
describe '#status' do
let(:runner) { create(:ci_runner, :instance, contacted_at: 1.second.ago) }
let(:runner) { build(:ci_runner, :instance) }
subject { runner.status }
......@@ -638,6 +638,45 @@ RSpec.describe Ci::Runner do
it { is_expected.to eq(:not_connected) }
end
context 'inactive but online' do
before do
runner.contacted_at = 1.second.ago
runner.active = false
end
it { is_expected.to eq(:online) }
end
context 'contacted 1s ago' do
before do
runner.contacted_at = 1.second.ago
end
it { is_expected.to eq(:online) }
end
context 'contacted long time ago' do
before do
runner.contacted_at = 1.year.ago
end
it { is_expected.to eq(:offline) }
end
end
describe '#deprecated_rest_status' do
let(:runner) { build(:ci_runner, :instance, contacted_at: 1.second.ago) }
subject { runner.deprecated_rest_status }
context 'never connected' do
before do
runner.contacted_at = nil
end
it { is_expected.to eq(:not_connected) }
end
context 'contacted 1s ago' do
before do
runner.contacted_at = 1.second.ago
......
......@@ -162,12 +162,12 @@ RSpec.describe Clusters::Applications::Runner do
it 'pauses associated runner' do
active_runner = create(:ci_runner, contacted_at: 1.second.ago)
expect(active_runner.status).to eq(:online)
expect(active_runner.active).to be_truthy
application_runner = create(:clusters_applications_runner, :scheduled, runner: active_runner)
application_runner.prepare_uninstall
expect(active_runner.status).to eq(:paused)
expect(active_runner.active).to be_falsey
end
end
......
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