When I attempt to rebuild a hosts configuration via hammer (or via the web UI) I get the following error:
Configuration rebuild failed for: Content_Host_Status and Refresh_Content_Host_Status.
Expected outcome:
The host configuration is rebuilt without error.
Foreman and Proxy versions:
foreman-3.3.0-1.el7.noarch
foreman-proxy-3.3.0-1.el7.noarch
Foreman and Proxy plugin versions:
katello-4.5.0-0.1.rc2.el7.noarch
Distribution and version:
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Cor
Other relevant data:
This problem seems to have been around since around the time I upgraded to 3.2/4.4, but I had not needed to rebuild host configs much so it flew under the radar. I had working around it by just running “hammer host rebuild-config --only DNS,DHCP,TFTP”.
Actually. I think its a interface issue. The register_rebuild method expects, that in the end a method is called, which returns a queue element. In case, e.g. self.changes.key?('build') is false, it does not get such a queue.
To fix this, I tested this successfully:
def refresh_content_host_status
if content_facet&.present?
self.host_statuses.where(type: ::Katello::HostStatusManager::STATUSES.map(&:name)).each do |status|
status.refresh!
end
end
refresh_global_status
end
def queue_refresh_content_host_status
if !new_record? && !build && self.changes.key?('build')
queue.create(id: "refresh_content_host_status_#{id}", name: _("Refresh Content Host Statuses for %s") % self,
priority: 300, action: [self, :refresh_content_host_status])
else
queue.create(id: "refresh_content_host_status_#{id}", name: _("Skip: Refresh Content Host Statuses for %s") % self,
priority: 300, action: [nil])
end
end
def reset_katello_status
self.host_statuses.where(type: ::Katello::HostStatusManager::STATUSES.map(&:name)).each do |status|
status.update!(:status => status.class.const_get(:UNKNOWN))
end
self.host_statuses.reload
true
end
def queue_reset_content_host_status
if should_reset_content_host_status?
logger.debug "Scheduling host status cleanup"
queue.create(id: "reset_content_host_status_#{id}", name: _("Mark Content Host Statuses as Unknown for %s") % self,
priority: 200, action: [self, :reset_katello_status])
else
queue.create(id: "reset_content_host_status_#{id}", name: _("Skip: Mark Content Host Statuses as Unknown for %s") % self,
priority: 200, action: [nil])
end
end
Yes, its not nice to create a queue element which runs “nil”. It doesn’t throw an error but I’m not sure if it has other drawbacks or can be solved better.