Refs #39068 - Check for persisted statuses when building global status#10993
Refs #39068 - Check for persisted statuses when building global status#10993synkd wants to merge 1 commit into
Conversation
54db0fd to
fbdc419
Compare
After theforeman#10962 was merged, a failure was found downstream in which a host showed a WARN status on the All Hosts page immediately after registration, although the same host showed OK for all statuses on its host details page. The cause of this appears to be that, at registration time, the host has a nil value for its execution status. When the `get_status()` method in `app/models/host/managed.rb` reads this nil status, it calls `host_statuses.new()` for the status. Because the host has no config reports, its status is eventually returned as status type `WARN` by the `to_global()` method in `app/models/host_status/configuration_status.rb`. This PR addresses this issue by checking whether all relevant statuses are also persisted when building global status for a host. Testing Steps: 1. Register a host to a Foreman server with the remote execution plugin enabled. 2. On the All Hosts page, verify that the status icon for the host is OK (green).
fbdc419 to
c8b47d1
Compare
LadislavVasina1
left a comment
There was a problem hiding this comment.
Looks good to me, automation made for this feature is passing with this patch.
LadislavVasina1
left a comment
There was a problem hiding this comment.
Sorry, dismissing my previous ACK, I accidentally checked the automation results against the incorrect branch.
|
Reacking, can confirm the test is passing on the correct branch. |
There was a problem hiding this comment.
Thanks @synkd
The fix is working as expected. Without this change, my newly-registered host shows a WARN global status because of an "Unknown execution status," but with the PR checked out, the host global status shows OK for both All Hosts list and host details.
There is still room for improvement in one place, however - The tooltip on the All Hosts page lists status text for irrelevant statuses (Execution & Inventory in this example):
Whereas host details correctly just shows "N/A" for the status text of irrelevant statuses:
I think it would also be worth it to fix that here.
After #10962 was merged, a failure was found downstream in which a host showed a WARN status on the All Hosts page immediately after registration, although the same host showed OK for all statuses on its host details page. The cause of this appears to be that, at registration time, the host has a nil value for its execution status. When the
get_status()method inapp/models/host/managed.rbreads this nil status, it callshost_statuses.new()for the status. Because the host has no config reports, its status is eventually returned as status typeWARNby theto_global()method inapp/models/host_status/configuration_status.rb.This PR addresses this issue by checking whether all relevant statuses are also persisted when building global status for a host.
Testing Steps: