Skip to content

Commit

Permalink
Fixes #38152 - Update lifecycle status to allow for empty support
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 committed Jan 20, 2025
1 parent 4b9bac9 commit d98bf88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/models/katello/rhel_lifecycle_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def self.end_of_day(date)
end

RHEL_EOS_SCHEDULE = { # dates that each support category ends
'RHEL10' => {
'full_support' => nil,
},
'RHEL9' => {
'full_support' => end_of_day('2027-05-31'),
'maintenance_support' => end_of_day('2032-05-31'),
Expand Down Expand Up @@ -74,6 +77,7 @@ def self.approaching_end_of_category(eos_schedule_index:)

def self.lifecycles_expire_soon
expiring = RHEL_EOS_SCHEDULE.collect do |index, schedules|
next if schedules['full_support'].blank?
expire_soon = schedules.except("full_support").select { |_k, v| (Time.now.utc..Time.now.utc + EOS_WARNING_THRESHOLD).cover?(v) }
{index => expire_soon} if expire_soon.present?
end
Expand All @@ -98,6 +102,8 @@ def self.to_status(rhel_eos_schedule_index: nil)
extended_support_end_date = RHEL_EOS_SCHEDULE[release]['extended_support']

case
when full_support_end_date.blank?
return FULL_SUPPORT
when Date.today <= full_support_end_date
return FULL_SUPPORT
when Date.today <= maintenance_support_end_date
Expand Down
11 changes: 10 additions & 1 deletion test/models/rhel_lifecycle_status_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RhelLifecycleStatusTest < ActiveSupport::TestCase
let(:status) { host.get_status(Katello::RhelLifecycleStatus) }

let(:release) { 'RHEL9' }
let(:release10) { 'RHEL10' }

def test_get_status
assert host.get_status(Katello::RhelLifecycleStatus)
Expand All @@ -35,7 +36,7 @@ def test_eos_schedule_constants
assert eos_schedule_data.key?(rhel_version)
assert eos_schedule_data[rhel_version].is_a?(Hash)
end
eos_schedule_data.each do |_, schedule|
eos_schedule_data.except('RHEL10').each do |_, schedule|
assert schedule.is_a?(Hash)
%w[full_support maintenance_support].each { |support_category| assert schedule.key?(support_category) }
schedule.each do |support_category, end_time|
Expand Down Expand Up @@ -116,6 +117,14 @@ def test_to_status_support_ended
assert_equal Katello::RhelLifecycleStatus::SUPPORT_ENDED, status.to_status
end

def test_empty_full_support_end_date
os.hosts << host
host.operatingsystem.update(:name => "RedHat", :major => "10", :minor => "0")
host.expects(:rhel_eos_schedule_index).returns(release10)
Katello::RhelLifecycleStatus.expects(:approaching_end_of_category).returns({})
assert_equal Katello::RhelLifecycleStatus::FULL_SUPPORT, status.to_status
end

def test_full_support_end_dates
assert_equal_arrays Katello::RhelLifecycleStatus::RHEL_EOS_SCHEDULE.keys, Katello::RhelLifecycleStatus.full_support_end_dates.keys
Katello::RhelLifecycleStatus::RHEL_EOS_SCHEDULE.each do |release, schedule|
Expand Down

0 comments on commit d98bf88

Please sign in to comment.