Skip to content

Commit

Permalink
Fixes #37388 - Drop Pulp 2 related code
Browse files Browse the repository at this point in the history
The PULP_FEATURE and PULP_NODE_FEATURE features were for Pulp 2. This is
never present in a current Katello installation and can be dropped.

It also replaces the deprecated default_capsule code, which is replaced
by pulp_primary.

In the template the code to handle primaries is disabled because it's
only shown for mirrors. A mirror is by definition not a primary, so it
can never trigger.
  • Loading branch information
ekohl committed Jul 18, 2024
1 parent cf5e05d commit ab383c3
Show file tree
Hide file tree
Showing 34 changed files with 23 additions and 343 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/katello/containers/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ KT.container = (function(){
getTag = function() {
return $('#tag_id').val();
},
// TODO: This only returns Pulp 2 proxies, which no longer exist
populateCapsules = function() {
var capsuleDropdown = $('#capsule_id'),
noCapsules = $("#no_capsules"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def show
end

def action_permission
if params[:action] == 'pulp_status' || params[:action] == 'pulp_storage'
if params[:action] == 'pulp_storage'
:view
else
super
Expand All @@ -23,7 +23,7 @@ def action_permission
helper 'bastion/layout'

append_view_path('app/views/foreman')
before_action :find_resource_and_status, :only => [:pulp_storage, :pulp_status]
before_action :find_resource, :only => [:pulp_storage]

def pulp_storage
@storage = @smart_proxy.pulp_disk_usage
Expand All @@ -38,30 +38,6 @@ def pulp_storage
format.json { render :json => {:success => false, :message => e} }
end
end

def pulp_status
pulp_connection = @proxy_status[:pulp] || @proxy_status[:pulpnode]
@pulp_status = pulp_connection.status
if @pulp_status['fatal']
Rails.logger.warn @pulp_status['fatal']
respond_to do |format|
format.html { render :plain => _('Error connecting to Pulp service') }
format.json { render :json => {:success => false, :message => @pulp_status['fatal']} }
end
else
respond_to do |format|
format.html { render :layout => false }
format.json { render :json => {:success => true, :message => @pulp_status} }
end
end
end
end

private

def find_resource_and_status
find_resource
find_status
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/fetch_pxe_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run
capsule = if input[:capsule_id].present?
SmartProxy.unscoped.find(input[:capsule_id])
else
SmartProxy.default_capsule!
SmartProxy.pulp_primary!
end

downloader = ::Katello::PxeFilesDownloader.new(repository, capsule)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/refresh_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def plan(repo, options = {})
User.as_anonymous_admin do
repo = ::Katello::Repository.find(repo.id)
plan_action(Actions::Pulp3::Orchestration::Repository::RefreshIfNeeded,
repo, SmartProxy.default_capsule!, :dependency => options[:dependency])
repo, SmartProxy.pulp_primary!, :dependency => options[:dependency])
repo.smart_proxy_alternate_content_sources.each do |smart_proxy_acs|
plan_action(::Actions::Pulp3::AlternateContentSource::RefreshRemote, smart_proxy_acs)
end
Expand Down
38 changes: 5 additions & 33 deletions app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'proxy_api'
require 'proxy_api/pulp'
require 'proxy_api/pulp_node'
require 'proxy_api/container_gateway'

module Katello
Expand All @@ -17,8 +15,6 @@ def refresh
end

PULP3_FEATURE = "Pulpcore".freeze
PULP_FEATURE = "Pulp".freeze
PULP_NODE_FEATURE = "Pulp Node".freeze
CONTAINER_GATEWAY_FEATURE = "Container_Gateway".freeze

DOWNLOAD_INHERIT = 'inherit'.freeze
Expand All @@ -36,7 +32,7 @@ def refresh
before_create :associate_lifecycle_environments
before_validation :set_default_download_policy

lazy_accessor :pulp_repositories, :initializer => lambda { |_s| pulp_node.extensions.repository.retrieve_all }
lazy_accessor :pulp_repositories, :initializer => lambda { |_s| pulp_api.extensions.repository.retrieve_all }

# A smart proxy's HTTP proxy is used for all related alternate content sources.
belongs_to :http_proxy, :inverse_of => :smart_proxies, :class_name => '::HttpProxy'
Expand Down Expand Up @@ -66,7 +62,7 @@ def refresh
:in => DOWNLOAD_POLICIES,
:message => _("must be one of the following: %s") % DOWNLOAD_POLICIES.join(', ')
}
scope :with_content, -> { with_features(PULP_FEATURE, PULP_NODE_FEATURE, PULP3_FEATURE) }
scope :with_content, -> { with_features(PULP3_FEATURE) }

def self.load_balanced
proxies = unscoped.with_content # load balancing is only supported for pulp proxies
Expand All @@ -86,10 +82,6 @@ def self.with_repo(repo)
end

def self.pulp_primary
unscoped.with_features(PULP_FEATURE).first || non_mirror_pulp3
end

def self.non_mirror_pulp3
found = unscoped.with_features(PULP3_FEATURE).order(:id).select { |proxy| !proxy.setting(PULP3_FEATURE, 'mirror') }
Rails.logger.warn("Found multiple smart proxies with mirror set to false. This is likely not intentional.") if found.count > 1
found.first
Expand All @@ -99,24 +91,8 @@ def self.pulp_primary!
pulp_primary || fail(_("Could not find a smart proxy with pulp feature."))
end

def self.default_capsule
pulp_primary
end

def self.default_capsule!
pulp_primary!
end

def self.with_environment(environment, include_default = false)
(pulp2_proxies_with_environment(environment, include_default) + pulpcore_proxies_with_environment(environment)).try(:uniq)
end

def self.pulp2_proxies_with_environment(environment, include_default = false)
features = [PULP_NODE_FEATURE]
features << PULP_FEATURE if include_default

unscoped.with_features(features).joins(:capsule_lifecycle_environments).
where(katello_capsule_lifecycle_environments: { lifecycle_environment_id: environment.id })
pulpcore_proxies_with_environment(environment).try(:uniq)
end

def self.pulpcore_proxies_with_environment(environment)
Expand Down Expand Up @@ -357,11 +333,11 @@ def pulp3_url(path = '/pulp/api/v3')
end

def pulp_mirror?
self.has_feature?(PULP_NODE_FEATURE) || self.setting(SmartProxy::PULP3_FEATURE, 'mirror')
self.setting(SmartProxy::PULP3_FEATURE, 'mirror')
end

def pulp_primary?
self.has_feature?(PULP_FEATURE) || self.setting(SmartProxy::PULP3_FEATURE, 'mirror') == false
!pulp_mirror?
end

def supported_pulp_types
Expand All @@ -376,10 +352,6 @@ def supported_pulp_types
supported_types
end

#deprecated methods
alias_method :pulp_node, :pulp_api
alias_method :default_capsule?, :pulp_primary?

def associate_organizations
self.organizations = Organization.all if self.pulp_primary?
end
Expand Down
51 changes: 0 additions & 51 deletions app/models/katello/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ def services(capsule_id = nil)
proxy = fetch_proxy(capsule_id)
services = [:candlepin, :candlepin_auth, :foreman_tasks, :katello_events, :candlepin_events]
services += [:pulp3, :pulp3_content] if proxy&.pulp3_enabled?
if proxy.nil? || proxy.has_feature?(SmartProxy::PULP_NODE_FEATURE) || proxy.has_feature?(SmartProxy::PULP_FEATURE)
services += [:pulp, :pulp_auth]
end

services
end
Expand Down Expand Up @@ -75,12 +72,6 @@ def ping_pulp3_content_without_auth(service_result, capsule_id)
end
end

def ping_pulp_without_auth(service_result, capsule_id)
exception_watch(service_result) do
Katello::Ping.pulp_without_auth(pulp_url(capsule_id))
end
end

def ping_candlepin_without_auth(service_result)
url = SETTINGS[:katello][:candlepin][:url]
exception_watch(service_result) do
Expand All @@ -89,16 +80,6 @@ def ping_candlepin_without_auth(service_result)
end
end

def ping_pulp_with_auth(service_result, pulp_without_auth_status, capsule_id)
exception_watch(service_result) do
if pulp_without_auth_status == OK_RETURN_CODE
Katello::Pulp::Server.config(pulp_url(capsule_id), User.remote_user).resources.user.retrieve_all
else
fail _("Skipped pulp_auth check after failed pulp check")
end
end
end

def ping_candlepin_with_auth(service_result)
exception_watch(service_result) do
status = Katello::Resources::Candlepin::CandlepinPing.ping
Expand Down Expand Up @@ -150,36 +131,6 @@ def packages
packages.split("\n").sort
end

def pulp_url(capsule_id)
proxy = fetch_proxy(capsule_id)
uri = URI.parse(proxy.pulp_url)
"#{uri.scheme}://#{uri.host.downcase}/pulp/api/v2/"
end

# this checks Pulp is running and responding without need
# for authentication. We don't use RestClient.options here
# because it returns empty string, which is not enough to say
# pulp is the one that responded
def pulp_without_auth(url)
json = backend_status(url, :pulp)

fail _("Pulp does not appear to be running at %s.") % url if json.empty?

if json['database_connection'] && json['database_connection']['connected'] != true
fail _("Pulp database connection issue at %s.") % url
end

if json['messaging_connection'] && json['messaging_connection']['connected'] != true
fail _("Pulp message bus connection issue at %s.") % url
end

unless all_pulp_workers_present?(json)
fail _("Not all necessary pulp workers running at %s.") % url
end

json
end

def pulp3_without_auth(url)
json = backend_status(url, :pulp)
fail _("Pulp does not appear to be running at %s.") % url if json.empty?
Expand Down Expand Up @@ -232,10 +183,8 @@ def ping_services_for_capsule(services, capsule_id)

ping_pulp3_without_auth(result[:pulp3], capsule_id) if result.include?(:pulp3)
ping_pulp3_content_without_auth(result[:pulp3_content], capsule_id) if result.include?(:pulp3_content)
ping_pulp_without_auth(result[:pulp], capsule_id) if result.include?(:pulp)
ping_candlepin_without_auth(result[:candlepin]) if result.include?(:candlepin)

ping_pulp_with_auth(result[:pulp_auth], result[:pulp][:status], capsule_id) if result.include?(:pulp_auth)
ping_candlepin_with_auth(result[:candlepin_auth]) if result.include?(:candlepin_auth)
ping_foreman_tasks(result[:foreman_tasks]) if result.include?(:foreman_tasks)
ping_katello_events(result[:katello_events]) if result.include?(:katello_events)
Expand Down
52 changes: 0 additions & 52 deletions app/services/katello/proxy_status/pulp.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/services/katello/proxy_status/pulp_node.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/services/katello/smart_proxy_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ def ==(other)
other.class == self.class && other.smart_proxy == smart_proxy
end

def default_capsule?
@smart_proxy.pulp_primary?
end

def lifecycle_environment_check(environment = nil, repository = nil)
environment = repository.environment if repository

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ child @lifecycle_environments => :lifecycle_environments do
attributes
end

if @capsule.has_feature?(SmartProxy::PULP_NODE_FEATURE) || @capsule.has_feature?(SmartProxy::PULP3_FEATURE)
if @capsule.has_feature?(SmartProxy::PULP3_FEATURE)
node :counts do |env|
{
:content_views => env.content_views.non_default.count
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<% if !@smart_proxy.new_record? && @smart_proxy.pulp_mirror? -%>
<div class="tab-pane" id="kt_environments">
<%= multiple_selects f, :lifecycle_environments, Katello::KTEnvironment.completer_scope(:organization_id => ::Organization.current.try(:id)), @smart_proxy.lifecycle_environment_ids, {:label => _('Lifecycle Environments')}, @smart_proxy.default_capsule? ? {:disabled => :disabled } : {} %>
<% if @smart_proxy.default_capsule? %>
<%= _("Lifecycle environments cannot be modifed on the default Smart proxy. The content from all Lifecycle Environments will exist on this Smart proxy.") % @smart_proxy.name %>
<% end %>
<%= multiple_selects f, :lifecycle_environments, Katello::KTEnvironment.completer_scope(:organization_id => ::Organization.current.try(:id)), @smart_proxy.lifecycle_environment_ids, {:label => _('Lifecycle Environments')} %>
</div>
<% end -%>
9 changes: 0 additions & 9 deletions app/views/smart_proxies/plugins/_pulp.html.erb

This file was deleted.

9 changes: 0 additions & 9 deletions app/views/smart_proxies/plugins/_pulp_node.html.erb

This file was deleted.

Loading

0 comments on commit ab383c3

Please sign in to comment.