Skip to content

Commit

Permalink
Refs #36928 - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Dec 8, 2023
1 parent 168cb30 commit ed31c3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ def registering_thru_load_balancer?(hostname)
def set_host_content_source(host, content_source_hostname)
content_source_id = get_content_source_id(content_source_hostname)
if registering_thru_load_balancer?(content_source_hostname)
Rails.logger.info "Host %s registered through load balancer %s" % [host.name, parent_host]
Rails.logger.info "Host %s registered through load balancer %s" % [host.name, content_source_hostname]
content_source_id = ::SmartProxy.behind_load_balancer(content_source_hostname)&.first&.id
end
Rails.logger.warn "Host %s registered through unknown proxy %s" % [host.name, parent_host] if content_source_id.nil?
Rails.logger.warn "Host %s registered through unknown proxy %s" % [host.name, content_source_hostname] if content_source_id.nil?
host.content_facet.update_attribute(:content_source_id, content_source_id)
end

Expand Down
12 changes: 9 additions & 3 deletions app/models/katello/concerns/host_managed_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def remote_execution_proxies(provider, *_rest)
.authorized
.where(name: name)
if result.blank?
result = SmartProxy.behind_load_balancer(name)
result = SmartProxy.authorized.behind_load_balancer(name)
end
end
proxies[:registered_through] = result
Expand All @@ -107,7 +107,7 @@ def remote_execution_proxies(provider, *_rest)
end

included do
prepend ::ForemanRemoteExecution::HostExtensions if ::Katello.with_remote_execution?
prepend ::ForemanRemoteExecution::HostExtensions
prepend Overrides

delegate :content_source_id, :single_content_view, :single_lifecycle_environment, :default_environment?, :single_content_view_environment?, :multi_content_view_environment?, :kickstart_repository_id, :bound_repositories,
Expand Down Expand Up @@ -198,7 +198,13 @@ def self.find_with_expiring_pools(_key, _operator, days_from_now)
property :content_views, 'ContentView', desc: 'Returns content views associated with the host'
property :installed_packages, array_of: 'InstalledPackage', desc: 'Returns a list of packages installed on the host'
end
end
rescue NameError => e
if e.respond_to?(:missing_name) && e.missing_name == 'ForemanRemoteExecution'
Rails.logger.warn "Foreman Remote Execution is not installed, skipping HostManagedExtensions"
else
raise e
end
end # of included block

def check_host_registration
if subscription_facet
Expand Down

0 comments on commit ed31c3b

Please sign in to comment.