-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs #37696 - Don't run sub facet fact parser on non registered hosts #11109
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,11 +298,12 @@ def backend_update_needed? | |
end | ||
|
||
def self.populate_fields_from_facts(host, parser, _type, _source_proxy) | ||
return unless host.subscription_facet # skip method if the host is not a registered host | ||
has_convert2rhel = parser.facts.key?('conversions.env.CONVERT2RHEL_THROUGH_FOREMAN') | ||
# Add in custom convert2rhel fact if system was converted using convert2rhel through Katello | ||
# We want the value nil unless the custom fact is present otherwise we get a 0 in the database which if debugging | ||
# might make you think it was converted2rhel but not with satellite, that is why I have the tenary below. | ||
facet = host.subscription_facet || host.build_subscription_facet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I also do not exactly understand the reasoning for the |
||
facet = host.subscription_facet | ||
facet.attributes = { | ||
convert2rhel_through_foreman: has_convert2rhel ? ::Foreman::Cast.to_bool(parser.facts['conversions.env.CONVERT2RHEL_THROUGH_FOREMAN']) : nil | ||
}.compact | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ChangeConvert2RhelToBoolean < ActiveRecord::Migration[6.1] | ||
def up | ||
change_column :katello_subscription_facets, :convert2rhel_through_foreman, :boolean, using: 'convert2rhel_through_foreman::boolean' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://api.rubyonrails.org/v7.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column implies it's not specified in the resulting SQL so it's up to the DB implementation. Reading https://www.postgresql.org/docs/current/sql-altertable.html I get the impression the default is to allow |
||
end | ||
|
||
def down | ||
change_column :katello_subscription_facets, :convert2rhel_through_foreman, :integer, using: 'convert2rhel_through_foreman::integer' | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the following also work?
That'd create the facet if the host has the special fact, and skip otherwise? (If we keep the
build_sub_facet
call below)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that in #11110 and ran a pipeline based on the packit build -- it passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an interesting thing to think about. AFAIK
populate_fields_from_facts
is called for every fact source, so also Puppet. That makes me think the current code will result in unstable values if both RHSM and Puppet are used. Your code to skip if no fact exists is probably more reliable, but also means no mechanism exists to clear the value.