diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 03:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 03:08:19 +0300 |
commit | c937ca4f20d47f5cc87300eae29dbb98ad0a956c (patch) | |
tree | 761a8febb2e27f7ac1a04c8f077546125818e546 /lib/gitlab/ci/runner_upgrade_check.rb | |
parent | 972f10aa90a29b400ee84ee66e720ec633102b33 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/runner_upgrade_check.rb')
-rw-r--r-- | lib/gitlab/ci/runner_upgrade_check.rb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/gitlab/ci/runner_upgrade_check.rb b/lib/gitlab/ci/runner_upgrade_check.rb index bc37affdf3f..d251ecf67dc 100644 --- a/lib/gitlab/ci/runner_upgrade_check.rb +++ b/lib/gitlab/ci/runner_upgrade_check.rb @@ -12,42 +12,41 @@ module Gitlab recommended: 'Upgrade is available and recommended for the runner.' }.freeze - def initialize - reset! - end - def check_runner_upgrade_status(runner_version) runner_version = ::Gitlab::VersionInfo.parse(runner_version) unless runner_version.is_a?(::Gitlab::VersionInfo) return :invalid unless runner_version.valid? releases = RunnerReleases.instance.releases - gitlab_minor_version = @gitlab_version.without_patch - - available_releases = releases - .reject { |release| release.major > @gitlab_version.major } - .reject do |release| - # Do not reject a patch update, even if the runner is ahead of the instance version - next false if release.same_minor_version?(runner_version) - release.without_patch > gitlab_minor_version + # Recommend patch update if there's a newer release in a same minor branch as runner + releases.each do |available_release| + if available_release.same_minor_version?(runner_version) && available_release > runner_version + return :recommended end + end - return :recommended if available_releases.any? { |available_rel| patch_update?(available_rel, runner_version) } - return :recommended if outside_backport_window?(runner_version, releases) - return :available if available_releases.any? { |available_rel| available_rel > runner_version } + # Recommend update if outside of backport window + if outside_backport_window?(runner_version, releases) + return :recommended + end - :not_available - end + # Consider update if there's a newer release within the currently deployed GitLab version + releases.each do |available_release| + if available_release.same_minor_version?(gitlab_version) && available_release > runner_version + return :available + end + end - def reset! - @gitlab_version = ::Gitlab::VersionInfo.parse(::Gitlab::VERSION) + :not_available end - public_class_method :instance - private + def gitlab_version + @gitlab_version ||= ::Gitlab::VersionInfo.parse(::Gitlab::VERSION) + end + def patch_update?(available_release, runner_version) # https://docs.gitlab.com/ee/policy/maintenance.html#patch-releases available_release.major == runner_version.major && |