Bug 1979092

Summary: Capsule cname is reported as opposed to hostname
Product: Red Hat Satellite Reporter: Taft Sanders <tasander>
Component: RH Cloud - InventoryAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.9.3CC: aruzicka, ehelms, jpathan, lhellebr, pcreech, sshtein
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: foreman_rh_cloud_5.0.32 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:29:32 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 Taft Sanders 2021-07-04 21:09:29 UTC
Description of problem:
When Satellite is known as a different name the notification feature from the task 'InsightsFullSync' looks for the Capsules name as 'SmartProxy.default_capsule.name'. If the cname and FQDN are different this will throw issues with finding the server.

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

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
# foreman-rake console
Loading production environment (Rails 6.0.3.4)
irb(main):001:0> ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST']
=> nil
irb(main):002:0> ::SmartProxy.default_capsule.name
=> "satellite.example.com"
irb(main):003:0> ::Host.unscoped.friendly.find(ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || ::SmartProxy.default_capsule.name)
Traceback (most recent call last):
        2: from lib/tasks/console.rake:5:in `block in <top (required)>'
        1: from (irb):3
ActiveRecord::RecordNotFound (can't find record with friendly id: "satellite.example.com")
irb(main):004:0> ::Host.unscoped.friendly.find("satellite.example.com")
Traceback (most recent call last):
        2: from lib/tasks/console.rake:5:in `block in <top (required)>'
        1: from (irb):4
ActiveRecord::RecordNotFound (can't find record with friendly id: "satellite.example.com")
irb(main):005:0> ::Host.unscoped.friendly.find("real.satellite.com")
=> #<Host::Managed id: 1, name: "real.satellite.com", last_compile: "2021-07-03 09:14:49", last_report: [FILTERED], updated_at: "2021-07-03 09:14:59", created_at: "2017-11-15 11:20:44", root_pass: [FILTERED], architecture_id: 1, operatingsystem_id: 13, environment_id: 2, ptable_id: 371, medium_id: nil, build: false, comment: "Satellite", disk: "", installed_at: nil, model_id: 1, hostgroup_id: 1260, owner_id: 3, owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: true, use_image: nil, image_file: nil, uuid: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", compute_resource_id: 2, puppet_proxy_id: 1, certname: "real.satellite.com", image_id: nil, organization_id: 1, location_id: 2, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: nil, provision_method: nil, grub_pass: "XXXXXXXX", global_status: 0, lookup_value_matcher: [FILTERED], discovery_rule_id: nil, openscap_proxy_id: 1, pxe_loader: "PXELinux BIOS", initiated_at: nil, build_errors: nil>

Expected results:


Additional info:
To workaround this bug, you need to change the internal Capsule name back to "real.satellite.com"

Steps:
1) Web UI -> Infrastructure -> Capsule -> Click Edit the internal Capsule -> Set the name to "real.satellite.com"

2) Restart the Satellite so the change can take effect in Dynflow

foreman-maintain service restart

3) After that try manually trigger the InsightFullSync task

Web UI -> Configure -> Insights -> Click Start Recommendation Sync.

4) Check it the ask can finish successfully.

Comment 2 Eric Helms 2021-07-20 14:47:06 UTC
The real solution to this is a feature being discussed in the upstream and looked at for the Satellite 7.0 release. The details and discussion can be found at: https://community.theforeman.org/t/infrastructure-roles/22001

Comment 3 Shimon Shtein 2022-03-07 14:45:21 UTC
I'll move to post once plugin version would be available

Comment 5 Lukáš Hellebrandt 2022-05-24 15:15:14 UTC
Verified with Sat 6.11 snap 20.0.

1) Created a Sat, imported manifest, registered host
2) Created some issue on the host that CRC would show as Advisory, in my case: SMBLoris (added `max smbd processes = 0` to /etc/samba/smb.conf global section)
3) Waited for the Advisory to show in CRC
4) Configure -> Insights -> ... -> Sync recommendations
5) Go to the task 4) created => It succeeded and the Advisories are now shown in Configure -> Insights
6) Infrastructure -> Capsules -> Edit the internal capsule
7) There are fields Name and URL, changed Name to `renamed-capsule.wrong.fqdn.com`
8) Repeated 4) and 5)
9) `foreman-maintain service restart`
1) Repeated 4) and 5)

Comment 8 errata-xmlrpc 2022-07-05 14:29:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498