Skip to content

Commit

Permalink
Refs #36693 - only update errata and RHEL lifecycle status
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Sep 1, 2023
1 parent 55f149b commit ecb4d4a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/models/katello/host/content_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def calculate_and_import_applicability
::Katello::Applicability::ApplicableContentHelper.new(self, ::Katello::Erratum, bound_repos).calculate_and_import
::Katello::Applicability::ApplicableContentHelper.new(self, ::Katello::ModuleStream, bound_repos).calculate_and_import
update_applicability_counts
self.host&.refresh_statuses(::Katello::HostStatusManager::STATUSES)
self.host&.refresh_statuses([::Katello::ErrataStatus, ::Katello::RhelLifecycleStatus])
end

def update_applicability_counts
Expand Down
10 changes: 2 additions & 8 deletions app/models/katello/rhel_lifecycle_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ def self.end_of_day(date)
}
}.freeze

def self.between_dates?(date1, date2)
return nil unless date1.present? && date2.present?
today = Date.today.beginning_of_day.utc
date1.present? && today >= date1.beginning_of_day.utc && today <= date2.end_of_day.utc
end

EOS_WARNING_THRESHOLD = 1.year

def self.status_map
Expand All @@ -75,7 +69,7 @@ def self.status_map
end

def self.approaching_end_of_category(eos_schedule_index:)
RHEL_EOS_SCHEDULE[eos_schedule_index].select { |k, v| (Time.now.utc .. Time.now.utc + EOS_WARNING_THRESHOLD).cover?(v) }
RHEL_EOS_SCHEDULE[eos_schedule_index].select { |_k, v| (Time.now.utc..Time.now.utc + EOS_WARNING_THRESHOLD).cover?(v) }
end

def self.to_status(rhel_eos_schedule_index: nil)
Expand All @@ -90,7 +84,7 @@ def self.to_status(rhel_eos_schedule_index: nil)
return APPROACHING_END_OF_MAINTENANCE
end
end

full_support_end_date = RHEL_EOS_SCHEDULE[release]['full_support']
maintenance_support_end_date = RHEL_EOS_SCHEDULE[release]['maintenance_support']
extended_support_end_date = RHEL_EOS_SCHEDULE[release]['extended_support']
Expand Down
6 changes: 5 additions & 1 deletion app/services/katello/registration_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ def finalize_registration(host)
host.subscription_facet.update_from_consumer_attributes(host.subscription_facet.candlepin_consumer.
consumer_attributes.except(:guestIds, :facts))
host.subscription_facet.save!
host.refresh_statuses(::Katello::HostStatusManager::STATUSES)
host.refresh_statuses([
::Katello::ErrataStatus,
::Katello::SubscriptionStatus,
::Katello::RhelLifecycleStatus
])
end

def set_host_collections(host, activation_keys)
Expand Down
5 changes: 0 additions & 5 deletions test/models/rhel_lifecycle_status_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ def test_eos_date_no_extended_support
assert_equal Date.today + 2.years, Katello::RhelLifecycleStatus.eos_date(eos_schedule_index: release)
end

def test_warn_date
fake_extended_support_end_date(Date.today + 2.years)
assert_equal Date.today + 2.years - Katello::RhelLifecycleStatus::EOS_WARNING_THRESHOLD, Katello::RhelLifecycleStatus.warn_date(eos_schedule_index: release)
end

def test_relevant
os.hosts << host
assert status.relevant?
Expand Down

0 comments on commit ecb4d4a

Please sign in to comment.