Skip to content

Commit e8508db

Browse files
committed
Refs #37696 - Don't run sub facet fact parser on non registered hosts
* When a host that is not registered with subscription manager tries to update facts we get an error "Content host must be unregistered before performing this action" This change causes the fact parser to skip if the host does not have a subscription facet, also changing the db column from int4 to boolean
1 parent 4bd1489 commit e8508db

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/models/katello/host/subscription_facet.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,12 @@ def backend_update_needed?
298298
end
299299

300300
def self.populate_fields_from_facts(host, parser, _type, _source_proxy)
301+
return unless host.subscription_facet # skip method if the host is not a registered host
301302
has_convert2rhel = parser.facts.key?('conversions.env.CONVERT2RHEL_THROUGH_FOREMAN')
302303
# Add in custom convert2rhel fact if system was converted using convert2rhel through Katello
303304
# We want the value nil unless the custom fact is present otherwise we get a 0 in the database which if debugging
304305
# might make you think it was converted2rhel but not with satellite, that is why I have the tenary below.
305-
facet = host.subscription_facet || host.build_subscription_facet
306+
facet = host.subscription_facet
306307
facet.attributes = {
307308
convert2rhel_through_foreman: has_convert2rhel ? ::Foreman::Cast.to_bool(parser.facts['conversions.env.CONVERT2RHEL_THROUGH_FOREMAN']) : nil
308309
}.compact
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class ChangeConvert2RhelToBoolean < ActiveRecord::Migration[6.1]
2+
def up
3+
change_column :katello_subscription_facets, :convert2rhel_through_foreman, :boolean, using: 'convert2rhel_through_foreman::boolean'
4+
end
5+
6+
def down
7+
change_column :katello_subscription_facets, :convert2rhel_through_foreman, :integer, using: 'convert2rhel_through_foreman::integer'
8+
end
9+
end

0 commit comments

Comments
 (0)