Bug 2277133

Summary: Kickstart Repository association is not deleted from a host when it is unregistered from satellite.
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: Hosts - ContentAssignee: Ian Ballou <iballou>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.14.3CC: ahumbe, iballou, jlenz, peter.vreman
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Patch, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 17:29:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sayan Das 2024-04-25 12:00:26 UTC
Description of problem:

Continuing from https://bugzilla.redhat.com/show_bug.cgi?id=2277130 , If we look at the unregistered host from UI as well as the database, It will still have a Kickstart repository ID associated. 

Now, due to the lack of CV and LCE associations, When someone tries to directly just rebuild that stale entry, The kickstart template will be generated just with the BaseOS kickstart repo and will miss the Appstream repo, leading to failures during provisioning process. 


Version-Release number of selected component (if applicable):

Red Hat Satellite 6.14.3 [ with https://github.com/Katello/katello/pull/10797/files applied ]

Red Hat Satellite 6.15.0 


How reproducible:

Always


Steps to Reproduce:

Exact same as https://bugzilla.redhat.com/show_bug.cgi?id=2277130


Actual results:

Same as https://bugzilla.redhat.com/show_bug.cgi?id=2277130

Additionally, if we look at the content_facet of the host, It will still have kickstart repository ID associated. 

Before:

irb(main):022:0> pp h.content_facet
#<Katello::Host::ContentFacet:0x000055d6e788d920
 id: 21,
 host_id: 28,
 uuid: "8d81043f-a295-4ba3-8ed1-37e1b50b20ea",
 kickstart_repository_id: 278,
 content_source_id: 1,
 installable_security_errata_count: 0,
 installable_enhancement_errata_count: 0,
 installable_bugfix_errata_count: 0,
 applicable_rpm_count: 16,
 upgradable_rpm_count: 0,
 applicable_module_stream_count: 0,
 upgradable_module_stream_count: 0,
 applicable_deb_count: 0,
 upgradable_deb_count: 0>

After:

irb(main):004:0> pp h.content_facet
#<Katello::Host::ContentFacet:0x0000559762f3e900
 id: 21,
 host_id: 28,
 uuid: nil,
 kickstart_repository_id: 278,
 content_source_id: 1,
 installable_security_errata_count: 0,
 installable_enhancement_errata_count: 0,
 installable_bugfix_errata_count: 0,
 applicable_rpm_count: 16,
 upgradable_rpm_count: 0,
 applicable_module_stream_count: 0,
 upgradable_module_stream_count: 0,
 applicable_deb_count: 0,
 upgradable_deb_count: 0>

The same would be visible in UI , when editing the host.

If we put the Host in Build mode, satellite allows doing so and just with the BaseOS kickstart repo URL which eventually leads to failed kickstart deployment, due to missing packages [ i.e. missing appstream kickstart repo ].


Expected results:

When registering a host, The kickstart_repository association should be removed from the host as well. 

So that when a user mistakenly tries to rebuild the host, It would show some sort of error with template rendering thus forcing the user to edit the host and select all relevant values and the save them, before retrying the build action. 


Additional info:

If i combine https://github.com/Katello/katello/pull/10797/files with host.content_facet.kickstart_repository = nil i.e. 

# git diff
diff --git a/app/services/katello/registration_manager.rb b/app/services/katello/registration_manager.rb
index e3add5b..9f93757 100644
--- a/app/services/katello/registration_manager.rb
+++ b/app/services/katello/registration_manager.rb
@@ -316,6 +316,8 @@ module Katello
           host.content_facet.applicable_errata = []
           host.content_facet.uuid = nil
           host.content_facet.content_view_environments = []
+          host.content_facet.content_source = ::SmartProxy.pulp_primary
+          host.content_facet.kickstart_repository = nil
           host.content_facet.save!
           Rails.logger.debug "remove_host_artifacts: marking CVEs unchanged to prevent backend update"
           host.content_facet.mark_cves_unchanged


It does the job at database level and also does not allow putting the host in build mode. 

But if I edit the host, And go to OS tab, I can still see the repository there. So I guess some additional UI level fix would be needed to maintain consistency.

Please check the support case 03796000 and the discussion on the same for additional information

Comment 2 Ian Ballou 2024-05-29 21:01:56 UTC
Created redmine issue https://projects.theforeman.org/issues/37518 from this bug

Comment 3 Eric Helms 2024-06-05 20:03:01 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/37518 has been resolved.

Comment 4 Eric Helms 2024-06-06 17:29:35 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.