katello 3.15.0.rc2 → 3.15.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ee4f1e17bf63eec8c349a58dbe28aea05c1736937fa253c921c997e50247f8
4
- data.tar.gz: 696c9f65f17d7a2405f4b2c807d6db42a269b728bb30cb10484fe0c6b75a88b5
3
+ metadata.gz: d7c699693c15591342b13df91353c83817bebe73159d71cb44af695b650decaf
4
+ data.tar.gz: a577aa95a181684ca801159c932943ebd6f91bacec215dc151e3e2de30d87cb3
5
5
  SHA512:
6
- metadata.gz: 882b95014f435cf75227bf1969ce47294f45988d29f757c61d6c5c3a02d43af75d4b4238b8c654609cc03fa1269bed5afbc43bc2590ff49d59fab908c508a812
7
- data.tar.gz: 9edd9187a9e65364ccd41687adf5a81414a8651eb9a02d20524e7d22fb56ddcd41d817b64d81112ba851ce7b13327eadb9640796e7f8db7e247936f819de9d90
6
+ metadata.gz: 074d5eb93cbeff706338e63c0e41113efe1e8b1ddc1537ac9d4190dc138c067ca8300579d4494aeed2a8eb5b76762728f902ec34d97ee5ad754ed31e4c586e60
7
+ data.tar.gz: 2e1a26e50825ef423edf40001003a8e7f0da557ae70df33920cafaeffc90c76bef6556715279096dabc815f2ba6a42bcd214a7b2e5a449724091ab4fc8d3496f
@@ -22,7 +22,6 @@ module Katello
22
22
  def self.parse_nvrea(name)
23
23
  name, suffix = extract_suffix(name)
24
24
  name, arch = extract_arch(name)
25
- return unless arch
26
25
 
27
26
  if (nvre = parse_nvre(name))
28
27
  nvre.merge(:suffix => suffix, :arch => arch).delete_if { |_k, v| v.nil? }
@@ -153,17 +153,14 @@ module Katello
153
153
  end
154
154
 
155
155
  unless params_to_query_for_delete.empty?
156
- DockerMetaTag.where(:id => repository_association_class.
157
- where(:repository_id => repo.id).
158
- select(:docker_meta_tag_id)).
159
- where(params_to_query_for_delete.join(" OR ")).delete_all
156
+ RepositoryDockerMetaTag.where(:docker_meta_tag => DockerMetaTag.where(params_to_query_for_delete.join(" OR "))).delete_all
160
157
  end
161
158
 
162
159
  metatags = []
163
160
  (tag_table_values - meta_tag_table_values).each do |schema1, schema2, name|
164
161
  metatags << DockerMetaTag.where(:schema1_id => schema1,
165
162
  :schema2_id => schema2,
166
- :name => name).create!
163
+ :name => name).first_or_create
167
164
  end
168
165
  repo.docker_meta_tags += metatags
169
166
  end
@@ -0,0 +1,94 @@
1
+ require 'pulp_2to3_migration_client'
2
+
3
+ module Katello
4
+ module Pulp3
5
+ class SwitchoverError < StandardError; end
6
+
7
+ class MigrationSwitchover
8
+ def initialize(*argv)
9
+ @migration = Katello::Pulp3::Migration.new(*argv)
10
+ end
11
+
12
+ def content_types
13
+ @migration.content_types_for_migration
14
+ end
15
+
16
+ def run
17
+ check_already_migrated_content
18
+ cleanup_v1_docker_tags if docker_migration?
19
+ migrated_content_type_check
20
+ combine_duplicate_docker_tags if docker_migration?
21
+ migrate_pulp3_hrefs
22
+ end
23
+
24
+ def docker_migration?
25
+ content_types.any? { |content_type| content_type.model_class::CONTENT_TYPE == "docker_tag" }
26
+ end
27
+
28
+ def migrate_pulp3_hrefs
29
+ content_types.each do |content_type|
30
+ content_type.model_class
31
+ .where.not("pulp_id=migrated_pulp3_href")
32
+ .update_all("pulp_id = migrated_pulp3_href")
33
+ end
34
+ end
35
+
36
+ def check_already_migrated_content
37
+ content_types.each do |content_type|
38
+ if content_type.model_class.where("pulp_id=migrated_pulp3_href").any?
39
+ Rails.logger.error("Content Switchover: #{content_type.label} seems to have already migrated content, switchover may fail. Did you already perform the switchover?")
40
+ end
41
+ end
42
+ end
43
+
44
+ def cleanup_v1_docker_tags
45
+ unmigrated_docker_tags = Katello::DockerTag.includes(:schema1_meta_tag, :schema2_meta_tag).where(migrated_pulp3_href: nil)
46
+ unmigrated_docker_tags.find_in_batches(batch_size: 50_000) do |batch|
47
+ to_delete = []
48
+
49
+ batch.each do |unmigrated_tag|
50
+ if unmigrated_tag.schema1_meta_tag && unmigrated_tag.schema1_meta_tag.schema2.try(:migrated_pulp3_href)
51
+ Rails.logger.warn("Content Switchover: Deleting Docker tag #{unmigrated_tag.name} with pulp id: #{unmigrated_tag.pulp_id}")
52
+ to_delete << unmigrated_tag.id
53
+ end
54
+ end
55
+ Katello::DockerMetaTag.where(:schema1_id => to_delete).update_all(:schema1_id => nil)
56
+ Katello::RepositoryDockerTag.where(:docker_tag_id => to_delete).delete_all
57
+ Katello::DockerTag.where(:id => to_delete).delete_all
58
+ end
59
+
60
+ Katello::DockerMetaTag.cleanup_tags
61
+ end
62
+
63
+ def combine_duplicate_docker_tags
64
+ to_delete = []
65
+ Katello::DockerTag.having("count(migrated_pulp3_href) > 1").group(:migrated_pulp3_href).pluck(:migrated_pulp3_href).each do |duplicate_href|
66
+ tags = Katello::DockerTag.where(:migrated_pulp3_href => duplicate_href).includes(:schema1_meta_tag, :schema2_meta_tag).to_a
67
+ main_tag = tags.pop
68
+ main_meta_v1 = main_tag.schema1_meta_tag
69
+ main_meta_v2 = main_tag.schema2_meta_tag
70
+
71
+ Katello::RepositoryDockerTag.where(:docker_tag_id => tags.map(&:id)).update_all(:docker_tag_id => main_tag.id)
72
+ Katello::RepositoryDockerMetaTag.joins(:docker_meta_tag).where("#{Katello::DockerMetaTag.table_name}.schema1_id" => tags).update_all(:docker_meta_tag_id => main_meta_v1.id) if main_meta_v1
73
+ Katello::RepositoryDockerMetaTag.joins(:docker_meta_tag).where("#{Katello::DockerMetaTag.table_name}.schema2_id" => tags).update_all(:docker_meta_tag_id => main_meta_v2.id) if main_meta_v2
74
+
75
+ to_delete += tags.map(&:id)
76
+ end
77
+
78
+ to_delete.each_slice(10_000) do |group|
79
+ Katello::RepositoryDockerTag.where(:docker_tag_id => group).delete_all
80
+ Katello::DockerMetaTag.where(:schema1_id => group).or(Katello::DockerMetaTag.where(:schema2_id => group)).delete_all
81
+ Katello::DockerTag.where(:id => group).delete_all
82
+ end
83
+ end
84
+
85
+ def migrated_content_type_check
86
+ content_types.each do |content_type|
87
+ if content_type.model_class.where(migrated_pulp3_href: nil).any?
88
+ fail SwitchoverError, "ERROR: at least one #{content_type.model_class.table_name} record has migrated_pulp3_href NULL value\n"
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,40 @@
1
+ class AddRepsoitoryDockerMetaTagFKey < ActiveRecord::Migration[5.2]
2
+ def up
3
+ Katello::RepositoryDockerMetaTag.where.not(:repository_id => Katello::Repository.select(:id)).delete_all
4
+ Katello::RepositoryDockerMetaTag.where.not(:docker_meta_tag_id => Katello::DockerMetaTag.select(:id)).delete_all
5
+
6
+ add_foreign_key :katello_repository_docker_meta_tags, :katello_repositories, :column => :repository_id
7
+ add_foreign_key :katello_repository_docker_meta_tags, :katello_docker_meta_tags, :column => :docker_meta_tag_id
8
+
9
+ query = "DELETE FROM katello_repository_docker_meta_tags T1
10
+ USING katello_repository_docker_meta_tags T2
11
+ WHERE T1.ctid < T2.ctid
12
+ AND T1.repository_id = T2.repository_id
13
+ AND T1.docker_meta_tag_id = T2.docker_meta_tag_id;"
14
+ ActiveRecord::Base.connection.execute(query)
15
+ add_index :katello_repository_docker_meta_tags, [:repository_id, :docker_meta_tag_id], :unique => true, :name => 'repository_docker_meta_tags_rid_dmtid'
16
+
17
+ Katello::RepositoryDockerTag.where.not(:repository_id => Katello::Repository.select(:id)).delete_all
18
+ Katello::RepositoryDockerTag.where.not(:docker_tag_id => Katello::DockerTag.select(:id)).delete_all
19
+
20
+ add_foreign_key :katello_repository_docker_tags, :katello_repositories, :column => :repository_id
21
+ add_foreign_key :katello_repository_docker_tags, :katello_docker_tags, :column => :docker_tag_id
22
+
23
+ query = "DELETE FROM katello_repository_docker_tags T1
24
+ USING katello_repository_docker_tags T2
25
+ WHERE T1.ctid < T2.ctid
26
+ AND T1.repository_id = T2.repository_id
27
+ AND T1.docker_tag_id = T2.docker_tag_id;"
28
+ ActiveRecord::Base.connection.execute(query)
29
+ add_index :katello_repository_docker_tags, [:repository_id, :docker_tag_id], :unique => true, :name => 'repository_docker_tags_rid_dtid'
30
+ end
31
+
32
+ def down
33
+ remove_foreign_key :katello_repository_docker_meta_tags, :katello_repositories
34
+ remove_foreign_key :katello_repository_docker_meta_tags, :katello_docker_meta_tags
35
+ remove_index :katello_repository_docker_meta_tags, [:repository_id, :docker_meta_tag_id]
36
+ remove_foreign_key :katello_repository_docker_tags, :katello_repositories
37
+ remove_foreign_key :katello_repository_docker_tags, :katello_docker_tags
38
+ remove_index :katello_repository_docker_tags, [:repository_id, :docker_tag_id]
39
+ end
40
+ end
@@ -3,20 +3,14 @@ require File.expand_path("../engine", File.dirname(__FILE__))
3
3
  namespace :katello do
4
4
  desc "Runs a Pulp 3 migration of pulp3 hrefs to pulp ids for supported content types."
5
5
  task :pulp3_content_switchover => :environment do
6
- migration_service = Katello::Pulp3::Migration.new(SmartProxy.pulp_master)
7
- content_types = migration_service.content_types_for_migration
8
-
9
- content_types.each do |content_type|
10
- if content_type.model_class.where(migrated_pulp3_href: nil).any?
11
- $stderr.print("ERROR: at least one #{content_type.model_class.table_name} record has migrated_pulp3_href NULL value\n")
12
- exit 1
6
+ begin
7
+ ActiveRecord::Base.transaction do
8
+ switchover_service = Katello::Pulp3::MigrationSwitchover.new(SmartProxy.pulp_master)
9
+ switchover_service.run
13
10
  end
14
- end
15
-
16
- content_types.each do |content_type|
17
- content_type.model_class
18
- .where.not("pulp_id=migrated_pulp3_href")
19
- .update_all("pulp_id = migrated_pulp3_href")
11
+ rescue Katello::Pulp3::SwitchoverError => e
12
+ $stderr.print(e.message)
13
+ exit 1
20
14
  end
21
15
  end
22
16
  end
@@ -6,25 +6,41 @@ namespace :katello do
6
6
  repository_types = Katello::Pulp3::Migration::REPOSITORY_TYPES
7
7
 
8
8
  repository_types.each do |type|
9
- filter = 'version_href is NULL OR remote_href is NULL'
10
-
11
- unless type == Katello::Repository::DOCKER_TYPE
12
- filter += ' OR publication_href is NULL'
9
+ # check version
10
+ nil_version_ids = Katello::Repository.with_type(type).where(version_href: nil).pluck(:id)
11
+ unless nil_version_ids.empty?
12
+ $stderr.print("ERROR: #{type} repositories with ID [#{nil_version_ids.join(',')}] have a NULL value for version_href\n")
13
+ exit 1
13
14
  end
14
- repositories = Katello::Repository.with_type(type).where(filter)
15
15
 
16
- if repositories.any?
17
- $stderr.print("ERROR: #{type} repository #{repositories.first.id} has a NULL value for remote_href, version_href, publication_href\n")
16
+ # check remote
17
+ nil_remote_ids = Katello::Repository.with_type(type).where(remote_href: nil).collect do |repo|
18
+ repo.id if repo.in_default_view? && !repo.root.url.nil?
19
+ end
20
+ nil_remote_ids.compact!
21
+ unless nil_remote_ids.empty?
22
+ $stderr.print("ERROR: #{type} repositories with ID [#{nil_remote_ids.join(',')}] have a NULL value for remote_href\n")
18
23
  exit 1
19
24
  end
20
25
 
26
+ # check publication
27
+ unless type == Katello::Repository::DOCKER_TYPE
28
+ nil_publication_ids = Katello::Repository.with_type(type).where(publication_href: nil).pluck(:id)
29
+ unless nil_publication_ids.empty?
30
+ $stderr.print("ERROR: #{type} repositories with ID [#{nil_publication_ids.join(',')}] have a NULL value for publication_href\n")
31
+ exit 1
32
+ end
33
+ end
34
+
35
+ # check distribution
21
36
  non_archived_repositories = Katello::Repository.with_type(type).non_archived
22
- with_no_distribution_references = non_archived_repositories
23
- .left_outer_joins(:distribution_references)
24
- .where(katello_distribution_references: { id: nil })
37
+ with_no_distribution_references = non_archived_repositories.
38
+ left_outer_joins(:distribution_references).
39
+ where(katello_distribution_references: { id: nil }).
40
+ pluck(:id)
25
41
 
26
42
  if with_no_distribution_references.any?
27
- $stderr.print("ERROR: A non-archive #{type} repository #{with_no_distribution_references.first.id} did not have a distribution reference\n")
43
+ $stderr.print("ERROR: Non-archived #{type} repositories with ID [#{with_no_distribution_references.join(',')}] have no distribution reference\n")
28
44
  exit 1
29
45
  end
30
46
  end
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "3.15.0.rc2".freeze
2
+ VERSION = "3.15.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.0.rc2
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-30 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1317,6 +1317,7 @@ files:
1317
1317
  - app/services/katello/pulp3/file_unit.rb
1318
1318
  - app/services/katello/pulp3/migration.rb
1319
1319
  - app/services/katello/pulp3/migration_plan.rb
1320
+ - app/services/katello/pulp3/migration_switchover.rb
1320
1321
  - app/services/katello/pulp3/module_stream.rb
1321
1322
  - app/services/katello/pulp3/package_group.rb
1322
1323
  - app/services/katello/pulp3/pulp_content_unit.rb
@@ -1892,6 +1893,7 @@ files:
1892
1893
  - db/migrate/20200109162354_drop_host_update_lock_setting.rb
1893
1894
  - db/migrate/20200121213430_katello_repository_rpms_id_big_int.rb
1894
1895
  - db/migrate/20200129172534_add_epoch_version_release_arch_to_katello_installed_packages.rb
1896
+ - db/migrate/20200402130013_add_repsoitory_docker_meta_tag_f_key.rb
1895
1897
  - db/seeds.d/101-locations.rb
1896
1898
  - db/seeds.d/102-organizations.rb
1897
1899
  - db/seeds.d/104-proxy.rb
@@ -4643,9 +4645,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
4643
4645
  version: '0'
4644
4646
  required_rubygems_version: !ruby/object:Gem::Requirement
4645
4647
  requirements:
4646
- - - ">"
4648
+ - - ">="
4647
4649
  - !ruby/object:Gem::Version
4648
- version: 1.3.1
4650
+ version: '0'
4649
4651
  requirements: []
4650
4652
  rubygems_version: 3.0.3
4651
4653
  signing_key: