katello 4.1.0 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +3 -1
  3. data/app/lib/actions/katello/content_view_version/create_repos.rb +1 -1
  4. data/app/lib/actions/katello/content_view_version/incremental_update.rb +12 -15
  5. data/app/lib/actions/katello/repository/clone_to_environment.rb +1 -1
  6. data/app/lib/actions/katello/repository/create.rb +9 -8
  7. data/app/lib/actions/katello/repository/create_root.rb +1 -1
  8. data/app/lib/actions/katello/repository_set/enable_repository.rb +1 -1
  9. data/app/lib/actions/pulp3/capsule_content/generate_metadata.rb +5 -0
  10. data/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb +3 -2
  11. data/app/lib/actions/pulp3/capsule_content/sync.rb +2 -1
  12. data/app/lib/actions/pulp3/content_view_version/destroy_exporter.rb +2 -2
  13. data/app/lib/actions/pulp3/orchestration/repository/create.rb +2 -2
  14. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +1 -0
  15. data/app/lib/actions/pulp3/orchestration/repository/sync.rb +1 -1
  16. data/app/lib/actions/pulp3/repository/create.rb +4 -3
  17. data/app/lib/actions/pulp3/repository/create_publication.rb +6 -3
  18. data/app/lib/actions/pulp3/repository/create_remote.rb +4 -0
  19. data/app/lib/actions/pulp3/repository/refresh_remote.rb +1 -1
  20. data/app/lib/actions/pulp3/repository/save_version.rb +9 -2
  21. data/app/lib/katello/agent/base_message.rb +7 -4
  22. data/app/lib/katello/agent/update_package_message.rb +8 -0
  23. data/app/models/katello/candlepin/repository_mapper.rb +1 -1
  24. data/app/models/katello/concerns/smart_proxy_extensions.rb +9 -0
  25. data/app/models/katello/content_view_version.rb +26 -2
  26. data/app/models/katello/ping.rb +1 -2
  27. data/app/models/katello/root_repository.rb +10 -0
  28. data/app/services/katello/pulp3/api/core.rb +3 -3
  29. data/app/services/katello/pulp3/api/docker.rb +3 -1
  30. data/app/services/katello/pulp3/docker_manifest.rb +3 -9
  31. data/app/services/katello/pulp3/docker_manifest_list.rb +1 -1
  32. data/app/services/katello/pulp3/repository.rb +19 -24
  33. data/app/services/katello/pulp3/repository/ansible_collection.rb +1 -1
  34. data/app/services/katello/pulp3/repository_mirror.rb +1 -1
  35. data/app/services/katello/pulp3/task.rb +16 -0
  36. data/app/services/katello/pulp3/task_group.rb +2 -2
  37. data/app/views/overrides/smart_proxies/_download_policy.erb +1 -1
  38. data/config/initializers/monkeys.rb +1 -0
  39. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-errata-modal.controller.js +1 -0
  40. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-errata.controller.js +1 -1
  41. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-traces.controller.js +1 -1
  42. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-module-streams.html +1 -1
  43. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-traces.html +1 -1
  44. data/lib/katello/tasks/repository.rake +4 -3
  45. data/lib/katello/version.rb +1 -1
  46. data/lib/monkeys/pulp3_13_checksumfix.rb +17 -0
  47. metadata +31 -74
  48. data/locale/bn/katello.edit.po +0 -8300
  49. data/locale/bn/katello.po.time_stamp +0 -0
  50. data/locale/cs/katello.edit.po +0 -8573
  51. data/locale/cs/katello.po.time_stamp +0 -0
  52. data/locale/de/katello.edit.po +0 -8319
  53. data/locale/de/katello.po.time_stamp +0 -0
  54. data/locale/en/katello.edit.po +0 -8297
  55. data/locale/en/katello.po.time_stamp +0 -0
  56. data/locale/es/katello.edit.po +0 -8317
  57. data/locale/es/katello.po.time_stamp +0 -0
  58. data/locale/fr/katello.edit.po +0 -8337
  59. data/locale/fr/katello.po.time_stamp +0 -0
  60. data/locale/gu/katello.edit.po +0 -8300
  61. data/locale/gu/katello.po.time_stamp +0 -0
  62. data/locale/hi/katello.edit.po +0 -8300
  63. data/locale/hi/katello.po.time_stamp +0 -0
  64. data/locale/it/katello.edit.po +0 -8303
  65. data/locale/it/katello.po.time_stamp +0 -0
  66. data/locale/ja/katello.edit.po +0 -8329
  67. data/locale/ja/katello.po.time_stamp +0 -0
  68. data/locale/kn/katello.edit.po +0 -8300
  69. data/locale/kn/katello.po.time_stamp +0 -0
  70. data/locale/ko/katello.edit.po +0 -8301
  71. data/locale/ko/katello.po.time_stamp +0 -0
  72. data/locale/mr/katello.edit.po +0 -8300
  73. data/locale/mr/katello.po.time_stamp +0 -0
  74. data/locale/or/katello.edit.po +0 -8300
  75. data/locale/or/katello.po.time_stamp +0 -0
  76. data/locale/pa/katello.edit.po +0 -8301
  77. data/locale/pa/katello.po.time_stamp +0 -0
  78. data/locale/pt/katello.edit.po +0 -8300
  79. data/locale/pt/katello.po.time_stamp +0 -0
  80. data/locale/pt_BR/katello.edit.po +0 -8315
  81. data/locale/pt_BR/katello.po.time_stamp +0 -0
  82. data/locale/ru/katello.edit.po +0 -8309
  83. data/locale/ru/katello.po.time_stamp +0 -0
  84. data/locale/ta/katello.edit.po +0 -8300
  85. data/locale/ta/katello.po.time_stamp +0 -0
  86. data/locale/te/katello.edit.po +0 -8300
  87. data/locale/te/katello.po.time_stamp +0 -0
  88. data/locale/zh_CN/katello.edit.po +0 -8328
  89. data/locale/zh_CN/katello.po.time_stamp +0 -0
  90. data/locale/zh_TW/katello.edit.po +0 -8303
  91. data/locale/zh_TW/katello.po.time_stamp +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f30d037b42e387abe07cb200218782b7918735e7ae3e6eff511491914e7dc4e3
4
- data.tar.gz: f92e5533113942c7f23d579f53dbe1474bbf68970d1ea9c53a850e98cfb7783c
3
+ metadata.gz: 1adb0b8312ecc97c2044f94caff1265923f1cc909ff71a67cb95303c55658c11
4
+ data.tar.gz: 9a0584aad43b18d1ce26d9cd5fde0709e7b34233e005fd5fff046960a4674693
5
5
  SHA512:
6
- metadata.gz: 9d408e0837a5efce7541213d3631d3d5f29dc552688cc54ca025d4add697c6443e0c6974b4bae66727eee4cbc34eb9cae37f8863b125b8725d1cdc71492480c0
7
- data.tar.gz: 8ee4d0ab24c2d2525338cf6e44f54e67416682e3ce56db109d4460dd93d5bbdac7e038fa72fa9371817fa0f5ffd75ad68c3797fac3d365610ac29e3fefd7c48d
6
+ metadata.gz: 4a887f66325269c29a3d1413184172d357ea097031fffad680789ebbb6c5d044eeb01b053e6e570cd8eb4d8528132ee8739d2b3224b14c73b412c19389d7f144
7
+ data.tar.gz: b54b6cfd02c914f976b38c6b5ad586192ffb7cf146957b8b1a09626560d046ecb4683760a7c90a72cb58558a3333fe972415c401f1afb06fd4bc96414aa9a536
@@ -19,7 +19,9 @@ module Katello
19
19
 
20
20
  def host_setup_extension
21
21
  if params['host']['lifecycle_environment_id']
22
- @host.update!(lifecycle_environment: KTEnvironment.readable.find(params['host']['lifecycle_environment_id']))
22
+ new_lce = KTEnvironment.readable.find(params['host']['lifecycle_environment_id'])
23
+ @host.content_facet.lifecycle_environment = new_lce
24
+ @host.update_candlepin_associations
23
25
  end
24
26
 
25
27
  super
@@ -10,7 +10,7 @@ module Actions
10
10
  source_repositories.each do |repositories|
11
11
  new_repository = repositories.first.build_clone(content_view: version.content_view,
12
12
  version: version)
13
- plan_action(Repository::Create, new_repository, true, false)
13
+ plan_action(Repository::Create, new_repository, clone: true)
14
14
  repository_mapping[repositories] = new_repository
15
15
  end
16
16
  end
@@ -18,6 +18,7 @@ module Actions
18
18
 
19
19
  # rubocop:disable Metrics/MethodLength
20
20
  # rubocop:disable Metrics/AbcSize
21
+ # rubocop:disable Metrics/CyclomaticComplexity
21
22
  def plan(old_version, environments, options = {})
22
23
  dep_solve = options.fetch(:resolve_dependencies, true)
23
24
  description = options.fetch(:description, '')
@@ -71,18 +72,22 @@ module Actions
71
72
  unit_map = pulp3_content_mapping(content)
72
73
 
73
74
  unless extended_repo_mapping.empty? || unit_map.values.flatten.empty?
74
- copy_action_outputs << plan_action(Pulp3::Repository::MultiCopyUnits, extended_repo_mapping, unit_map,
75
- dependency_solving: dep_solve).output
75
+ sequence do
76
+ copy_action_outputs << plan_action(Pulp3::Repository::MultiCopyUnits, extended_repo_mapping, unit_map,
77
+ dependency_solving: dep_solve).output
78
+ repos_to_clone.each do |source_repos|
79
+ if separated_repo_map[:pulp3_yum].keys.include?(source_repos)
80
+ copy_repos(repository_mapping[source_repos])
81
+ end
82
+ end
83
+ end
76
84
  end
77
85
  end
78
86
 
79
87
  if separated_repo_map[:other].keys.flatten.present?
80
88
  repos_to_clone.each do |source_repos|
81
89
  if separated_repo_map[:other].keys.include?(source_repos)
82
- copy_action_outputs += copy_repos(repository_mapping[source_repos],
83
- new_content_view_version,
84
- content,
85
- dep_solve)
90
+ copy_repos(repository_mapping[source_repos])
86
91
  end
87
92
  end
88
93
  end
@@ -138,19 +143,11 @@ module Actions
138
143
  end
139
144
  end
140
145
 
141
- def copy_repos(new_repo, new_version, content, dep_solve)
142
- copy_output = []
146
+ def copy_repos(new_repo)
143
147
  sequence do
144
- solve_dependencies = new_version.content_view.solve_dependencies || dep_solve
145
- copy_output += copy_deb_content(new_repo, solve_dependencies, content[:deb_ids])
146
- copy_output += copy_yum_content(new_repo, solve_dependencies,
147
- content[:package_ids],
148
- content[:errata_ids])
149
-
150
148
  plan_action(Katello::Repository::MetadataGenerate, new_repo)
151
149
  plan_action(Katello::Repository::IndexContent, id: new_repo.id)
152
150
  end
153
- copy_output
154
151
  end
155
152
 
156
153
  # For a given repo, find it's instances in both the new and old component versions.
@@ -10,7 +10,7 @@ module Actions
10
10
 
11
11
  sequence do
12
12
  if clone.new_record?
13
- plan_action(Repository::Create, clone, true, false)
13
+ plan_action(Repository::Create, clone, clone: true)
14
14
  else
15
15
  #only clear if it should be empty, but its not
16
16
  plan_optional_pulp_action([Actions::Pulp::Repository::Clear], clone, SmartProxy.pulp_primary)
@@ -2,19 +2,18 @@ module Actions
2
2
  module Katello
3
3
  module Repository
4
4
  class Create < Actions::EntryAction
5
- include Actions::Katello::PulpSelector
6
-
7
- def plan(repository, clone = false, plan_create = false)
5
+ def plan(repository, args = {})
6
+ clone = args[:clone] || false
7
+ force_repo_create = args[:force_repo_create] || false
8
8
  repository.save!
9
9
  root = repository.root
10
10
 
11
11
  action_subject(repository)
12
12
 
13
13
  org = repository.organization
14
- pulp2_create_action = plan_create ? Actions::Pulp::Repository::CreateInPlan : Actions::Pulp::Repository::Create
15
14
  sequence do
16
- create_action = plan_pulp_action([pulp2_create_action, Pulp3::Orchestration::Repository::Create],
17
- repository, SmartProxy.pulp_primary)
15
+ create_action = plan_action(Pulp3::Orchestration::Repository::Create,
16
+ repository, SmartProxy.pulp_primary, force_repo_create)
18
17
 
19
18
  return if create_action.error
20
19
 
@@ -25,8 +24,10 @@ module Actions
25
24
  if repository.product.redhat?
26
25
  plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => repository.content_id)
27
26
  else
28
- content_create = plan_action(Katello::Product::ContentCreate, root)
29
- plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => content_create.input[:content_id])
27
+ unless root.content
28
+ content_create = plan_action(Katello::Product::ContentCreate, root)
29
+ plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => content_create.input[:content_id])
30
+ end
30
31
  end
31
32
  end
32
33
 
@@ -10,7 +10,7 @@ module Actions
10
10
  repository.relative_path = repository.custom_repo_path
11
11
  repository.save!
12
12
  action_subject(repository)
13
- plan_action(::Actions::Katello::Repository::Create, repository, false, true)
13
+ plan_action(::Actions::Katello::Repository::Create, repository)
14
14
  end
15
15
 
16
16
  def humanized_name
@@ -15,7 +15,7 @@ module Actions
15
15
  fail ::Katello::Errors::ConflictException, _("The repository is already enabled")
16
16
  end
17
17
  repository = mapper.build_repository
18
- plan_action(Repository::Create, repository, false, true)
18
+ plan_action(Repository::Create, repository, clone: false)
19
19
  action_subject(repository)
20
20
  plan_self
21
21
  end
@@ -22,6 +22,11 @@ module Actions
22
22
  end
23
23
 
24
24
  def invoke_external_task
25
+ if input[:options][:sync_task_output] &&
26
+ ::Katello::Pulp3::Task.publication_href(input[:options][:sync_task_output]).present?
27
+ return input[:options][:sync_task_output]
28
+ end
29
+
25
30
  repository = ::Katello::Repository.find(input[:repository_id])
26
31
  smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id])
27
32
  output[:response] = repository.backend_service(smart_proxy).with_mirror_adapter.create_publication
@@ -19,9 +19,10 @@ module Actions
19
19
  if options[:use_repository_version]
20
20
  repo.backend_service(smart_proxy).with_mirror_adapter.refresh_distributions(:use_repository_version => true)
21
21
  elsif tasks && tasks[:pulp_tasks] && tasks[:pulp_tasks].first
22
- publication_href = tasks[:pulp_tasks].first[:created_resources].first
23
- if publication_href
22
+ if (publication_href = ::Katello::Pulp3::Task.publication_href(tasks[:pulp_tasks]))
24
23
  repo.backend_service(smart_proxy).with_mirror_adapter.refresh_distributions(:publication => publication_href)
24
+ else
25
+ fail "Unable to refresh distribution for repo #{repository.id}, could not find a publication_href"
25
26
  end
26
27
  end
27
28
  end
@@ -5,7 +5,8 @@ module Actions
5
5
  include ::Actions::Helpers::SmartProxySyncHistoryHelper
6
6
  def plan(repository, smart_proxy, options = {})
7
7
  sequence do
8
- plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :options => options)
8
+ sync_task = plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :options => options)
9
+ options[:sync_task_output] = sync_task.output[:pulp_tasks]
9
10
  plan_action(GenerateMetadata, repository, smart_proxy, options)
10
11
  end
11
12
  end
@@ -1,13 +1,13 @@
1
1
  module Actions
2
2
  module Pulp3
3
3
  module ContentViewVersion
4
- class DestroyExporter < Pulp3::Abstract
4
+ class DestroyExporter < Pulp3::AbstractAsyncTask
5
5
  input_format do
6
6
  param :smart_proxy_id, Integer
7
7
  param :exporter_data, Hash
8
8
  end
9
9
 
10
- def run
10
+ def invoke_external_task
11
11
  ::Katello::Pulp3::ContentViewVersion::Export.new(smart_proxy: smart_proxy).destroy_exporter(input[:exporter_data][:pulp_href])
12
12
  end
13
13
  end
@@ -3,9 +3,9 @@ module Actions
3
3
  module Orchestration
4
4
  module Repository
5
5
  class Create < Pulp3::Abstract
6
- def plan(repository, smart_proxy)
6
+ def plan(repository, smart_proxy, force = false)
7
7
  sequence do
8
- create_action = plan_action(Actions::Pulp3::Repository::Create, repository, smart_proxy)
8
+ create_action = plan_action(Actions::Pulp3::Repository::Create, repository, smart_proxy, force)
9
9
  plan_action(Actions::Pulp3::Repository::SaveVersion, repository, repository_details: create_action.output[:response])
10
10
 
11
11
  if repository.content_view.default? || !smart_proxy.pulp_primary?
@@ -6,6 +6,7 @@ module Actions
6
6
  def plan(repository, smart_proxy, options = {})
7
7
  options[:contents_changed] = (options && options.key?(:contents_changed)) ? options[:contents_changed] : true
8
8
  publication_content_type = !::Katello::RepositoryTypeManager.find(repository.content_type).pulp3_skip_publication
9
+
9
10
  sequence do
10
11
  if options[:source_repository] && publication_content_type
11
12
  plan_self(source_repository_id: options[:source_repository].id, target_repository_id: repository.id, smart_proxy_id: smart_proxy.id)
@@ -11,7 +11,7 @@ module Actions
11
11
 
12
12
  force_fetch_version = true if options[:optimize] == false
13
13
  version_output = plan_action(Pulp3::Repository::SaveVersion, repository, tasks: action_output[:pulp_tasks], :force_fetch_version => force_fetch_version).output
14
- plan_action(Pulp3::Orchestration::Repository::GenerateMetadata, repository, smart_proxy, :contents_changed => version_output[:contents_changed])
14
+ plan_action(Pulp3::Orchestration::Repository::GenerateMetadata, repository, smart_proxy, :contents_changed => version_output[:contents_changed], :skip_publication_creation => version_output[:publication_provided])
15
15
  plan_self(:subaction_output => version_output)
16
16
  end
17
17
  end
@@ -2,13 +2,14 @@ module Actions
2
2
  module Pulp3
3
3
  module Repository
4
4
  class Create < Pulp3::Abstract
5
- def plan(repository, smart_proxy)
6
- plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id)
5
+ def plan(repository, smart_proxy, force = false)
6
+ plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :force => force)
7
7
  end
8
8
 
9
9
  def run
10
10
  repo = ::Katello::Repository.find(input[:repository_id])
11
- output[:response] = repo.backend_service(smart_proxy).with_mirror_adapter.create
11
+ force = input[:force] || false
12
+ output[:response] = repo.backend_service(smart_proxy).with_mirror_adapter.create(force)
12
13
  end
13
14
  end
14
15
  end
@@ -5,14 +5,17 @@ module Actions
5
5
  middleware.use Actions::Middleware::ExecuteIfContentsChanged
6
6
  def plan(repository, smart_proxy, options)
7
7
  sequence do
8
- action = plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :contents_changed => options[:contents_changed], :options => options)
8
+ action = plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :contents_changed => options[:contents_changed],
9
+ :skip_publication_creation => options[:skip_publication_creation])
9
10
  plan_action(SavePublication, repository, action.output, :contents_changed => options[:contents_changed])
10
11
  end
11
12
  end
12
13
 
13
14
  def invoke_external_task
14
- repository = ::Katello::Repository.find(input[:repository_id])
15
- output[:response] = repository.backend_service(smart_proxy).with_mirror_adapter.create_publication
15
+ unless input[:skip_publication_creation]
16
+ repository = ::Katello::Repository.find(input[:repository_id])
17
+ output[:response] = repository.backend_service(smart_proxy).with_mirror_adapter.create_publication
18
+ end
16
19
  end
17
20
  end
18
21
  end
@@ -10,6 +10,10 @@ module Actions
10
10
  repo = ::Katello::Repository.find(input[:repository_id])
11
11
  output[:response] = repo.backend_service(smart_proxy).create_remote
12
12
  end
13
+
14
+ def rescue_strategy
15
+ Dynflow::Action::Rescue::Skip
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -9,7 +9,7 @@ module Actions
9
9
  def invoke_external_task
10
10
  repo = ::Katello::Repository.find(input[:repository_id])
11
11
  backend = repo.backend_service(smart_proxy)
12
- backend.update_remote if backend.remote_needs_updates?
12
+ backend.update_remote
13
13
  end
14
14
  end
15
15
  end
@@ -9,17 +9,24 @@ module Actions
9
9
 
10
10
  def run
11
11
  repo = ::Katello::Repository.find(input[:repository_id])
12
-
13
12
  if input[:force_fetch_version]
14
13
  version_href = fetch_version_href(repo)
15
14
  elsif input[:repository_details].present?
16
15
  version_href = input[:repository_details][:latest_version_href]
17
16
  elsif input[:tasks].present?
18
- version_href = input[:tasks].last[:created_resources].first
17
+ version_href = ::Katello::Pulp3::Task.version_href(input[:tasks])
19
18
  else
20
19
  version_href = fetch_version_href(repo)
21
20
  end
22
21
 
22
+ output[:publication_provided] = false
23
+ if input[:tasks].present?
24
+ if (publication_href = ::Katello::Pulp3::Task.publication_href(input[:tasks]))
25
+ repo.update(:publication_href => publication_href)
26
+ output[:publication_provided] = true
27
+ end
28
+ end
29
+
23
30
  if version_href
24
31
  if repo.version_href != version_href || input[:force_fetch_version]
25
32
  output[:contents_changed] = true
@@ -12,10 +12,7 @@ module Katello
12
12
  replyto: reply_to,
13
13
  request: {
14
14
  args: [
15
- units,
16
- {
17
- importkeys: true
18
- }
15
+ units, options
19
16
  ],
20
17
  classname: "Content",
21
18
  cntr: [[], {}],
@@ -30,6 +27,12 @@ module Katello
30
27
  }
31
28
  end
32
29
 
30
+ def options # may be overridden by children
31
+ {
32
+ importkeys: true
33
+ }
34
+ end
35
+
33
36
  def to_s
34
37
  json.to_json
35
38
  end
@@ -10,7 +10,15 @@ module Katello
10
10
 
11
11
  protected
12
12
 
13
+ def options
14
+ ops = super
15
+ ops[:all] = true if @packages.blank?
16
+ ops
17
+ end
18
+
13
19
  def units
20
+ return [{ type_id: @content_type, unit_key: {}}] if @packages.blank?
21
+
14
22
  @packages.map do |package|
15
23
  {
16
24
  type_id: @content_type,
@@ -44,7 +44,7 @@ module Katello
44
44
  end
45
45
 
46
46
  def validate!
47
- return if katello_content_type == Repository::OSTREE_TYPE
47
+ return if katello_content_type == Repository::OSTREE_TYPE || Setting[:content_disconnected]
48
48
  substitutor.validate_substitutions(content, substitutions)
49
49
  end
50
50
 
@@ -89,6 +89,10 @@ module Katello
89
89
  end
90
90
 
91
91
  def self.with_environment(environment, include_default = false)
92
+ (pulp2_proxies_with_environment(environment, include_default) + pulpcore_proxies_with_environment(environment)).try(:uniq)
93
+ end
94
+
95
+ def self.pulp2_proxies_with_environment(environment, include_default = false)
92
96
  features = [PULP_NODE_FEATURE]
93
97
  features << PULP_FEATURE if include_default
94
98
 
@@ -96,6 +100,11 @@ module Katello
96
100
  where(katello_capsule_lifecycle_environments: { lifecycle_environment_id: environment.id })
97
101
  end
98
102
 
103
+ def self.pulpcore_proxies_with_environment(environment)
104
+ unscoped.where(id: unscoped.select { |p| p.pulp_mirror? }.pluck(:id)).joins(:capsule_lifecycle_environments).
105
+ where(katello_capsule_lifecycle_environments: { lifecycle_environment_id: environment.id })
106
+ end
107
+
99
108
  def self.sync_needed?(environment)
100
109
  Setting[:foreman_proxy_content_auto_sync] && unscoped.with_environment(environment).any?
101
110
  end
@@ -231,7 +231,19 @@ module Katello
231
231
  end
232
232
 
233
233
  def available_packages
234
- library_packages.where.not(:id => packages)
234
+ # The simple/obvious solution is:
235
+ # library_packages.where.not(:id => packages)
236
+ # However, when the list of exclusions is large, the SQL "NOT IN" clause
237
+ # is extremely inefficient, and it is much better to use a
238
+ # "LEFT OUTER JOIN" with a subquery.
239
+ # ActiveRecord .joins() only supports subqueries by supplying raw SQL. We
240
+ # use .to_sql to avoid hard-coding raw SQL for self.packages, although
241
+ # .to_sql may also be somewhat brittle. For example, see:
242
+ # https://github.com/rails/rails/issues/18379
243
+ library_packages.joins(
244
+ "LEFT OUTER JOIN (#{packages.select('id').to_sql}) AS exclude_rpms ON " \
245
+ 'katello_rpms.id = exclude_rpms.id'
246
+ ).where('exclude_rpms.id IS NULL')
235
247
  end
236
248
 
237
249
  def srpms
@@ -262,7 +274,19 @@ module Katello
262
274
  end
263
275
 
264
276
  def available_errata
265
- library_errata.where.not(:id => errata)
277
+ # The simple/obvious solution is:
278
+ # library_errata.where.not(:id => errata)
279
+ # However, when the list of exclusions is large, the SQL "NOT IN" clause
280
+ # is extremely inefficient, and it is much better to use a
281
+ # "LEFT OUTER JOIN" with a subquery.
282
+ # ActiveRecord .joins() only supports subqueries by supplying raw SQL. We
283
+ # use .to_sql to avoid hard-coding raw SQL for self.errata, although
284
+ # .to_sql may also be somewhat brittle. For example, see:
285
+ # https://github.com/rails/rails/issues/18379
286
+ library_errata.joins(
287
+ "LEFT OUTER JOIN (#{errata.select('id').to_sql}) AS exclude_errata ON " \
288
+ 'katello_errata.id = exclude_errata.id'
289
+ ).where('exclude_errata.id IS NULL')
266
290
  end
267
291
 
268
292
  def file_units