2018-10-08 14:50:39 +00:00
# frozen_string_literal: true
2020-04-21 15:21:10 +00:00
require 'redis'
2017-05-25 14:16:25 +00:00
module SystemCheck
module App
class RedisVersionCheck < SystemCheck :: BaseCheck
2021-05-20 06:10:43 +00:00
# Redis 5.x will be deprecated
# https://gitlab.com/gitlab-org/gitlab/-/issues/331468
MIN_REDIS_VERSION = '5.0.0'
2022-07-05 15:08:48 +00:00
RECOMMENDED_REDIS_VERSION = " 6.0.0 "
2020-04-21 15:21:10 +00:00
set_name " Redis version >= #{ RECOMMENDED_REDIS_VERSION } ? "
@custom_error_message = ''
2017-05-25 14:16:25 +00:00
def check?
2020-04-21 15:21:10 +00:00
redis_version = Gitlab :: Redis :: Queues . with do | redis |
redis . info [ 'redis_version' ]
end
status = true
if ! redis_version
@custom_error_message = " Could not retrieve the Redis version. Please check if your settings are correct "
status = false
elsif Gem :: Version . new ( redis_version ) < Gem :: Version . new ( MIN_REDIS_VERSION )
@custom_error_message = " Your Redis version #{ redis_version } is not supported anymore. Update your Redis server to a version >= #{ RECOMMENDED_REDIS_VERSION } "
status = false
elsif Gem :: Version . new ( redis_version ) < Gem :: Version . new ( RECOMMENDED_REDIS_VERSION )
@custom_error_message = " Support for your Redis version #{ redis_version } has been deprecated and will be removed soon. Update your Redis server to a version >= #{ RECOMMENDED_REDIS_VERSION } "
status = false
end
2017-05-25 14:16:25 +00:00
2020-04-21 15:21:10 +00:00
status
2017-05-25 14:16:25 +00:00
end
def show_error
try_fixing_it (
2020-04-21 15:21:10 +00:00
@custom_error_message
2017-05-25 14:16:25 +00:00
)
for_more_information (
2020-10-12 15:08:32 +00:00
'doc/administration/redis/index.html#redis-replication-and-failover-using-the-non-bundled-redis'
2017-05-25 14:16:25 +00:00
)
fix_and_rerun
end
end
end
end