Class: Gitlab::Ci::RunnerUpgradeCheck

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/gitlab/ci/runner_upgrade_check.rb

Constant Summary collapse

STATUSES =
{
  invalid: 'Runner version is not valid.',
  not_available: 'Upgrade is not available for the runner.',
  available: 'Upgrade is available for the runner.',
  recommended: 'Upgrade is available and recommended for the runner.'
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeRunnerUpgradeCheck

Returns a new instance of RunnerUpgradeCheck.


15
16
17
# File 'lib/gitlab/ci/runner_upgrade_check.rb', line 15

def initialize
  reset!
end

Instance Method Details

#check_runner_upgrade_status(runner_version) ⇒ Object

Raises:

  • (ArgumentError)

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/ci/runner_upgrade_check.rb', line 19

def check_runner_upgrade_status(runner_version)
  return :invalid unless runner_version

  releases = RunnerReleases.instance.releases
  parsed_runner_version = runner_version.is_a?(::Gitlab::VersionInfo) ? runner_version : ::Gitlab::VersionInfo.parse(runner_version)

  raise ArgumentError, "'#{runner_version}' is not a valid version" unless parsed_runner_version.valid?

  available_releases = releases.reject { |release| release > @gitlab_version }

  return :recommended if available_releases.any? { |available_release| patch_update?(available_release, parsed_runner_version) }
  return :recommended if outside_backport_window?(parsed_runner_version, releases)
  return :available if available_releases.any? { |available_release| available_release > parsed_runner_version }

  :not_available
end

#reset!Object


36
37
38
# File 'lib/gitlab/ci/runner_upgrade_check.rb', line 36

def reset!
  @gitlab_version = ::Gitlab::VersionInfo.parse(::Gitlab::VERSION)
end