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.
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 )
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.
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.