katello 3.18.3 → 3.18.3.1
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 +4 -4
- data/app/controllers/katello/api/registry/registry_proxies_controller.rb +2 -4
- data/app/lib/katello/util/hostgroup_facets_helper.rb +126 -0
- data/app/models/katello/concerns/hostgroup_extensions.rb +3 -1
- data/app/models/katello/concerns/redhat_extensions.rb +9 -8
- data/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb +1 -1
- data/lib/katello/tasks/fix_hostgroup_facets.rake +8 -0
- data/lib/katello/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9aff3d142eea532e4af243e46c2b98a4cc1016a60f652d2dd9514dc9f416371
|
4
|
+
data.tar.gz: ea80686280189f05d2ffcbfe8e3cf0406fa2b985082b43e15338f62bca099209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b569aa5d2a488f3f248c4e29dfaf4c51ad1c014b9bcd2c20bf1c99f09f27d57b4490f1e8fd9c5f78b65a1f584e3f2f1262b91f6d0b57cb9c487781176a16de52
|
7
|
+
data.tar.gz: d0f344773b0172a608ca677effbb942fbf2b62386cf1179aefe3e8faf7fa5e0c16940cffb834a3e7be3007c6314525a09883989b51e714191160baa4dba65470
|
@@ -167,11 +167,9 @@ module Katello
|
|
167
167
|
end
|
168
168
|
|
169
169
|
if (manifest_response = redirect_client { Resources::Registry::Proxy.get(@_request.fullpath, headers) })
|
170
|
-
#
|
171
|
-
logger.debug filter_sensitive_data(manifest_response)
|
170
|
+
#for some requests, we get a redirect, but for others we get the actual manifest in response
|
172
171
|
results = JSON.parse(manifest_response)
|
173
|
-
|
174
|
-
response.header['Docker-Content-Digest'] = "sha256:#{Digest::SHA256.hexdigest(manifest_response)}"
|
172
|
+
response.header['Docker-Content-Digest'] = manifest_response.headers[:docker_content_digest]
|
175
173
|
# https://docs.docker.com/registry/spec/manifest-v2-2/
|
176
174
|
# If its v2 schema 2 only the mediaType attribute will be present in the manifest
|
177
175
|
media_type = results['mediaType']
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# Used exclusively by fix_hostgroup_facets.rake task
|
2
|
+
module Katello
|
3
|
+
module Util
|
4
|
+
class HostgroupFacetsHelper
|
5
|
+
def initialize
|
6
|
+
@logger = Logger.new($stdout)
|
7
|
+
end
|
8
|
+
|
9
|
+
def interested_hostgroups
|
10
|
+
groups = ::Hostgroup.unscoped.where(
|
11
|
+
id: Katello::Hostgroup::ContentFacet.
|
12
|
+
where(content_source_id: nil,
|
13
|
+
kickstart_repository_id: nil,
|
14
|
+
content_view_id: nil,
|
15
|
+
lifecycle_environment_id: nil).select(:hostgroup_id))
|
16
|
+
parents = groups.select { |group| group.parent.blank? }
|
17
|
+
children = groups.reject { |group| group.parent.blank? }
|
18
|
+
# we want the parents to get created before the children
|
19
|
+
# hence the order
|
20
|
+
parents + children
|
21
|
+
end
|
22
|
+
|
23
|
+
def pick_facet_values(hg)
|
24
|
+
# This call looks at the audit logs for a host group.
|
25
|
+
# Pries out information related to lce, ks, cv and content_source_id from the audit logs.
|
26
|
+
# The audit logs typically only contain updates.
|
27
|
+
# So if the user changed just the content_view_id, then that is the only thing marked as audited_changes.
|
28
|
+
# Hence we need to go through all the audit logs until we have information on lce, ks, cv and cs.
|
29
|
+
# If there was only one audit log and that was during the creation of hostgroup
|
30
|
+
# the audited changes look like this
|
31
|
+
# ```ruby
|
32
|
+
# {
|
33
|
+
# content_view_id: 10,
|
34
|
+
# kickstart_repository_id: 1000
|
35
|
+
# ......
|
36
|
+
# }
|
37
|
+
# ```
|
38
|
+
# However if you updated the hostgroup and set the kickstart_repository_id, or
|
39
|
+
# content_view_id then audited changes look like
|
40
|
+
# ```ruby
|
41
|
+
# {
|
42
|
+
# content_view_id: [10, 11],
|
43
|
+
# kickstart_repository_id: [1000, 1200]
|
44
|
+
# ......
|
45
|
+
# }
|
46
|
+
# ```
|
47
|
+
# So the code says "if the attribute value is an array pick the last value else just keep the value as it is "
|
48
|
+
|
49
|
+
# Further along it is to be noted that `hostgroup.audits` returns the audits ordered by the version number in ascending order, so the latest audit will be `hostgroup.audits.last`
|
50
|
+
|
51
|
+
# We want to iterate though each audit from latest audit to start, and as soon as we find a content_view_id key or kickstart_repository_id key or lifecycle environment_id key or content_source_id key we want it to be set once.
|
52
|
+
|
53
|
+
# So if I had an audit history like
|
54
|
+
# ``` ruby
|
55
|
+
# {
|
56
|
+
# content_view_id: 10,
|
57
|
+
# kickstart_repository_id: 1000,
|
58
|
+
# version:1
|
59
|
+
# ......
|
60
|
+
# },
|
61
|
+
# {
|
62
|
+
# content_view_id: [10, 11],
|
63
|
+
# kickstart_repository_id: [1000, 1200],
|
64
|
+
# version: 2
|
65
|
+
# ......
|
66
|
+
# }
|
67
|
+
# ```
|
68
|
+
|
69
|
+
# The code would start at version 2, notice that cv_id and ks_repo were set there
|
70
|
+
# and keep them as the final.
|
71
|
+
# So when it goes to version 1 since cv_id and ks_repo are already set,
|
72
|
+
# it will ignore. It will finally
|
73
|
+
# return {content_view_id: 11, kickstart_repository_id: 1200}
|
74
|
+
facet_values = {}
|
75
|
+
hg.audits.reverse_each do |audit|
|
76
|
+
hg_changes = audit.audited_changes.slice("lifecycle_environment_id",
|
77
|
+
"kickstart_repository_id",
|
78
|
+
"content_view_id",
|
79
|
+
"content_source_id")
|
80
|
+
facet_values = hg_changes.merge(facet_values)
|
81
|
+
end
|
82
|
+
|
83
|
+
values = facet_values.map do |k, v|
|
84
|
+
v = v[-1] if v.is_a? Array
|
85
|
+
[k, v]
|
86
|
+
end
|
87
|
+
values.to_h.with_indifferent_access
|
88
|
+
end
|
89
|
+
|
90
|
+
def main
|
91
|
+
bad_hgs = []
|
92
|
+
good_hgs = []
|
93
|
+
|
94
|
+
groups = interested_hostgroups.each do |hg|
|
95
|
+
facet = hg.content_facet
|
96
|
+
values = pick_facet_values(hg)
|
97
|
+
if !values.empty? && facet.update(values)
|
98
|
+
good_hgs << { hostgroup: hg, facet_values: values }
|
99
|
+
else
|
100
|
+
bad_hgs << { hostgroup: hg, facet_values: values }
|
101
|
+
facet.save(validate: false)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
unless bad_hgs.empty?
|
106
|
+
@logger.warn "Some of the hostgroups reported a validation error. "\
|
107
|
+
"The hostgroups have been updated. "\
|
108
|
+
"Check via the Web UI."
|
109
|
+
|
110
|
+
bad_hgs.each do |bad_group|
|
111
|
+
@logger.warn "Hostgroup #{bad_group[:hostgroup]}"
|
112
|
+
@logger.warn "Facet Values #{bad_group[:facet_values]}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
unless good_hgs.empty?
|
116
|
+
@logger.info "Following hostgroups were succesfully updated."
|
117
|
+
good_hgs.each do |good_group|
|
118
|
+
@logger.info "Hostgroup #{good_group[:hostgroup]}"
|
119
|
+
@logger.info "Facet Values #{good_group[:facet_values]}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
@logger.info("#{groups.count} Hostgroup(s) were updated.")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -107,7 +107,9 @@ module Katello
|
|
107
107
|
return true unless operatingsystem
|
108
108
|
|
109
109
|
if operatingsystem.respond_to? :kickstart_repos
|
110
|
-
|
110
|
+
operatingsystem.kickstart_repos(self, content_facet: content_facet).any? do |repo|
|
111
|
+
repo[:id] == (content_facet&.kickstart_repository_id || content_facet&.kickstart_repository&.id)
|
112
|
+
end
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
@@ -42,10 +42,11 @@ module Katello
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def kickstart_repos(host)
|
46
|
-
distros = distribution_repositories(host).where(distribution_bootable: true)
|
47
|
-
|
48
|
-
|
45
|
+
def kickstart_repos(host, content_facet: nil)
|
46
|
+
distros = distribution_repositories(host, content_facet: content_facet).where(distribution_bootable: true)
|
47
|
+
content_facet ||= host.content_facet
|
48
|
+
if distros && content_facet&.content_source
|
49
|
+
distros.map { |distro| distro.to_hash(content_facet.content_source) }
|
49
50
|
else
|
50
51
|
[]
|
51
52
|
end
|
@@ -65,10 +66,10 @@ module Katello
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
def distribution_repositories(host)
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
def distribution_repositories(host, content_facet: nil)
|
70
|
+
content_facet ||= host.content_facet
|
71
|
+
content_view = content_facet.try(:content_view) || host.try(:content_view)
|
72
|
+
lifecycle_environment = content_facet.try(:lifecycle_environment) || host.try(:lifecycle_environment)
|
72
73
|
if content_view && lifecycle_environment && host.os && host.architecture
|
73
74
|
Katello::Repository.in_environment(lifecycle_environment).in_content_views([content_view]).
|
74
75
|
where(:distribution_arch => host.architecture.name).
|
@@ -46,7 +46,7 @@ class MoveKatelloFieldsFromHostgroups < ActiveRecord::Migration[6.0]
|
|
46
46
|
content_facet.kickstart_repository_id = kickstart_repository_id
|
47
47
|
content_facet.content_view_id = content_view_id
|
48
48
|
content_facet.lifecycle_environment_id = lifecycle_environment_id
|
49
|
-
unless content_facet.save
|
49
|
+
unless content_facet.save(validate: false)
|
50
50
|
Rails.logger.warn("Unable to save content facet hostgroup for #{content_facet.inspect} ")
|
51
51
|
Rails.logger.warn(content_facet.errors.full_messages.join("\n"))
|
52
52
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
namespace :katello do
|
2
|
+
desc "This task collates hostgroup content facts that were missed during the upgrade from audit.\
|
3
|
+
It then updates the hostgroup content_facet accordingly."
|
4
|
+
task :fix_hostgroup_facets => :environment do
|
5
|
+
User.current = User.anonymous_admin
|
6
|
+
::Katello::Util::HostgroupFacetsHelper.new.main
|
7
|
+
end
|
8
|
+
end
|
data/lib/katello/version.rb
CHANGED
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.18.3
|
4
|
+
version: 3.18.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- N/A
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -1182,6 +1182,7 @@ files:
|
|
1182
1182
|
- app/lib/katello/util/docker_manifest_clause_generator.rb
|
1183
1183
|
- app/lib/katello/util/errata.rb
|
1184
1184
|
- app/lib/katello/util/filter_clause_generator.rb
|
1185
|
+
- app/lib/katello/util/hostgroup_facets_helper.rb
|
1185
1186
|
- app/lib/katello/util/http_proxy.rb
|
1186
1187
|
- app/lib/katello/util/model.rb
|
1187
1188
|
- app/lib/katello/util/module_stream_clause_generator.rb
|
@@ -4490,6 +4491,7 @@ files:
|
|
4490
4491
|
- lib/katello/tasks/clean_old_file_repos.rake
|
4491
4492
|
- lib/katello/tasks/clean_published_repo_directories.rake
|
4492
4493
|
- lib/katello/tasks/delete_orphaned_content.rake
|
4494
|
+
- lib/katello/tasks/fix_hostgroup_facets.rake
|
4493
4495
|
- lib/katello/tasks/import_applicability.rake
|
4494
4496
|
- lib/katello/tasks/import_subscriptions.rake
|
4495
4497
|
- lib/katello/tasks/jenkins.rake
|
@@ -5064,7 +5066,7 @@ homepage: http://www.katello.org
|
|
5064
5066
|
licenses:
|
5065
5067
|
- GPL-2.0
|
5066
5068
|
metadata: {}
|
5067
|
-
post_install_message:
|
5069
|
+
post_install_message:
|
5068
5070
|
rdoc_options: []
|
5069
5071
|
require_paths:
|
5070
5072
|
- lib
|
@@ -5079,8 +5081,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
5079
5081
|
- !ruby/object:Gem::Version
|
5080
5082
|
version: '0'
|
5081
5083
|
requirements: []
|
5082
|
-
rubygems_version: 3.1.
|
5083
|
-
signing_key:
|
5084
|
+
rubygems_version: 3.1.6
|
5085
|
+
signing_key:
|
5084
5086
|
specification_version: 4
|
5085
5087
|
summary: Content and Subscription Management plugin for Foreman
|
5086
5088
|
test_files: []
|