Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2145267

Summary: After successfully built a host, Monitoring - Host statuses reports it within Pending Installation
Product: Red Hat Satellite Reporter: Gianfranco Sigrisi <gsigrisi>
Component: HostsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.12.0CC: aruzicka, bmertens, inecas, saydas, wpinheir
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, 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 12:55:37 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:
Attachments:
Description Flags
Monitor / Host statuses none

Description Gianfranco Sigrisi 2022-11-23 16:46:34 UTC
Created attachment 1926752 [details]
Monitor / Host statuses

Description of problem:

After building a host, the Monitor / Host statuses report the hosts in Pending Installation status, even if successfully built.

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

6.12 (it was already there even with 6.11)

How reproducible:

Always

Steps to Reproduce:
1. Build a host
2. Verify that the /var/log/foreman/production.log contains: *host is built*
3. Click Monitor / Host statuses
4. Verify that the host in within Pending Installation

Actual results:

The host in within Monitor / Host statuses / Pending Installation host list

Expected results:

The host must be in the section Monitor / Host statuses / Installed

Additional info:
From: /var/log/foreman/production.log

2022-11-23T13:41:06 [I|app|f96bf385] Started POST "/unattended/built?token=8454dc1d-22da-4eb3-a0c9-82a520c44212&Content-Type=text%2Fplain&url=http%3A%2F%2Fcapsule.example.com%3A8000" for 192.168.4.236 at 2022-11-23 13:41:06 +0100
2022-11-23T13:41:06 [I|app|f96bf385] Processing by UnattendedController#built as TEXT
2022-11-23T13:41:06 [I|app|f96bf385] unattended: vera-wiedrich.apps.example.com is built!

Host name is a random name.

Comment 3 Sayan Das 2022-11-23 19:52:33 UTC
I can confirm that this issue actually exists and it is because, the "host_status" or "HostStatus::BuildStatus" for the host is marked as 1 instead of 0.

foreman=# select * from host_status where host_id = 18;
 id  |            type             | status | host_id |        reported_at         
-----+-----------------------------+--------+---------+----------------------------
 117 | HostStatus::BuildStatus     |      1 |      18 | 2022-11-23 19:11:57.382996
 119 | Katello::SubscriptionStatus |      5 |      18 | 2022-11-23 19:18:38.128692
 120 | Katello::ErrataStatus       |      3 |      18 | 2022-11-23 19:18:38.134766
(3 rows)


So even if my satellite tells me this i.e.

# grep 839638d5 /var/log/foreman/production.log
2022-11-24T00:48:33 [I|app|839638d5] Started POST "/unattended/built?token=0dbd0975-52d0-4494-9754-22e339463a8e" for 192.168.239.169 at 2022-11-24 00:48:33 +0530
2022-11-24T00:48:33 [I|app|839638d5] Processing by UnattendedController#built as TEXT
2022-11-24T00:48:33 [I|app|839638d5]   Parameters: {"token"=>"0dbd0975-52d0-4494-9754-22e339463a8e"}
2022-11-24T00:48:33 [I|app|839638d5] unattended: rh7.sat.syslab.pnq2.redhat.com is built!
2022-11-24T00:48:37 [I|app|839638d5] Deploying TFTP PXELinux configuration for rh7.sat.syslab.pnq2.redhat.com
2022-11-24T00:48:37 [I|app|839638d5] Deploying TFTP PXEGrub2 configuration for rh7.sat.syslab.pnq2.redhat.com
2022-11-24T00:48:37 [I|app|839638d5] Deploying TFTP PXEGrub configuration for rh7.sat.syslab.pnq2.redhat.com
2022-11-24T00:48:38 [I|app|839638d5] Deploying TFTP iPXE configuration for rh7.sat.syslab.pnq2.redhat.com
2022-11-24T00:48:38 [I|app|839638d5] Processed 5 tasks from queue 'Host::Managed Main', completed 5/5
2022-11-24T00:48:38 [I|aud|839638d5] Host::Base (18) update event on build true, false
2022-11-24T00:48:38 [I|aud|839638d5] Host::Base (18) update event on installed_at , 2022-11-23 19:18:33 UTC
2022-11-24T00:48:38 [I|app|839638d5] ForemanWebhooks::EventSubscriber: build_exited.event.foreman event received
2022-11-24T00:48:38 [I|app|839638d5] ForemanWebhooks::EventSubscriber: host_updated.event.foreman event received
2022-11-24T00:48:38 [I|app|839638d5] Completed 201 Created in 4966ms (ActiveRecord: 271.2ms | Allocations: 197108)

The HostStatus::BuildStatus value has not been updated for the host .


If you check the rake console output i.e. 

# cat << EOF | foreman-rake console
> conf.echo = false
> pp HostStatus::Status.where(host_id: 18)
> pp Host.find(18).build_status
> pp Host.find(18).build
> EOF
Loading production environment (Rails 6.0.4.7)
Switch to inspect mode.
conf.echo = false
pp HostStatus::Status.where(host_id: 18)
[#<HostStatus::BuildStatus:0x00005580f99e1f40
  id: 117,
  type: "HostStatus::BuildStatus",
  status: 1,
  host_id: 18,
  reported_at: "[FILTERED]">,
 #<Katello::SubscriptionStatus:0x00005580f8d8a530
  id: 119,
  type: "Katello::SubscriptionStatus",
  status: 5,
  host_id: 18,
  reported_at: "[FILTERED]">,
 #<Katello::ErrataStatus:0x00005580f73b0fb0
  id: 120,
  type: "Katello::ErrataStatus",
  status: 3,
  host_id: 18,
  reported_at: "[FILTERED]">]

pp Host.find(18).build_status
0

pp Host.find(18).build
false


So it's just the host_statuses table that is not getting updated ( specifically the value of HostStatus::BuildStatus )

Comment 4 Sayan Das 2022-11-23 20:07:43 UTC
Surprisingly, when I go to Hosts --> Alll Hosts --> Open that host and expand the "Host status" card , It simply tells me

Build	 Installed	51 minutes ago

And following shows me expected value as well.

# cat << EOF | foreman-rake console
conf.echo = false
pp Host.find(18)&.build
EOF

Loading production environment (Rails 6.0.4.7)
Switch to inspect mode.
conf.echo = false
pp Host.find(18)&.build
false


The main code seems to be in https://github.com/theforeman/foreman/blob/develop/app/models/host_status/build_status.rb , while i can't exactly pinpoint where the issue is , It seems once the "HostStatus::BuildStatus" value is being added for a Host, it does not gets updated later at all.

Comment 5 Marek Hulan 2022-11-24 08:36:57 UTC
This should be fixed as described in the upstream issue (comment #4), we need to properly store the state in the DB so we can search by it. It shouldn't be calculated during the runtime.

Comment 8 Adam Ruzicka 2023-11-24 14:14:43 UTC
This is BZ is what causes the search in https://bugzilla.redhat.com/show_bug.cgi?id=2166143 to not work. In theory we could probably close the other BZ as a duplicate

Comment 11 Sayan Das 2024-02-19 08:09:30 UTC
(In reply to Marek Hulan from comment #5)
> This should be fixed as described in the upstream issue (comment #4), we
> need to properly store the state in the DB so we can search by it. It
> shouldn't be calculated during the runtime.

Hello Marek and Adam,

I hope you are doing well. Are there any chances of targeting this BZ for Sat 6.16.0? 


-- Sayan

Comment 13 Eric Helms 2024-06-06 12:55:37 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.