Foreman 3.6.1 -- hammer host update

Hello,

I use the following command to apply a hostgroup to a host:

hammer host update --name “pc1234” --operatingsystem “Fedora 36” --new-location “Default Location” --hostgroup “fedora36” --organization “My Organization”

This command works as expected with Foreman 3.5.1. After an update to Foreman 3.6.1 the following error message is displayed:

Could not update the host:
Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug.

foreman-proxy-3.6.1-1.el8
foreman-3.6.1-1.el8
CentOS 8 Stream

2023-05-23T08:01:31 [I|app|8fea8833] Parameters: {“organization_id”=>1, “host”=>{“name”=>“pc1234”, “operatingsystem_id”=>2, “hostgroup_id”=>1, “content_facet_attributes”=>{}, “subscription_facet_attributes”=>{}, “location_id”=>2}, “apiv”=>“v2”, “id”=>“64”}
2023-05-23T08:01:31 [I|app|8fea8833] Authorized user admin(Admin User)
2023-05-23T08:01:31 [I|app|8fea8833] set_up_content_view_environment: cv_id=, env_id=
2023-05-23T08:01:31 [W|app|8fea8833] Action failed
2023-05-23T08:01:31 [I|app|8fea8833] Backtrace for ‘Action failed’ error (ActiveModel::UnknownAttributeError): unknown attribute ‘content_view_id’ for Katello::Host::ContentFacet.

Best regards,
Tom

same behavior with:

hammer host update --name “pc1234” --operatingsystem “Fedora 36” --new-location “Default Location” –content-view “Fedora 36” --hostgroup “fedora36” --organization “My Organization”

2023-05-23T08:57:48 [I|app|6374a493] Parameters: {“organization_id”=>1, “host”=>{“name”=>“pc1234”, “operatingsystem_id”=>2, “hostgroup_id”=>1, “content_facet_attributes”=>{“content_view_id”=>2}, “subscription_facet_attributes”=>{}, “location_id”=>2}, “apiv”=>“v2”, “id”=>“64”}
2023-05-23T08:57:48 [I|app|6374a493] Authorized user admin(Admin User)
2023-05-23T08:57:48 [I|app|6374a493] set_up_content_view_environment: cv_id=2, env_id=
2023-05-23T08:57:48 [W|app|6374a493] Action failed
2023-05-23T08:57:48 [I|app|6374a493] Backtrace for ‘Action failed’ error (ActiveModel::UnknownAttributeError): unknown attribute ‘content_view_id’ for Katello::Host::ContentFacet.

Do we really have to wait for Katello 4.9? I can not believe that :confused:

Bug-Report:

@jeremylenz, can you please check if Bug #36137: Can't update host with Katello plugin installed - Katello - Foreman resolves the API issue and can be backported for Foreman 3.6?

I have replaced all mentioned files (service restart etc.) but nothing has changed. Same error message when I use hammer to change the hostgroup. In both scenarios (with and without replaced files) I can change the hostgroup via the GUI without any problems. Only hammer won’t work.

No you don’t! This is in Katello 4.8.0.

(Unlike Foreman, for Katello issues the “Target Version” field is your best bet for determining what version of Katello a fix will end up in.)

I guess that patch fixes hosts only, but not hostgroups :confused:

Who can help to fix my issue?

What version of Katello do you have? Is the error the same as you’ve posted above?

Hello,

katello-4.8.0-1.el8

This is my problem:

hammer host update --name “pc1234” --operatingsystem “Fedora 36” --new-location “Default Location” –content-view “Fedora 36” --hostgroup “fedora36” --organization “My Organization”

2023-05-23T08:57:48 [I|app|6374a493] Parameters: {“organization_id”=>1, “host”=>{“name”=>“pc1234”, “operatingsystem_id”=>2, “hostgroup_id”=>1, “content_facet_attributes”=>{“content_view_id”=>2}, “subscription_facet_attributes”=>{}, “location_id”=>2}, “apiv”=>“v2”, “id”=>“64”}
2023-05-23T08:57:48 [I|app|6374a493] Authorized user admin(Admin User)
2023-05-23T08:57:48 [I|app|6374a493] set_up_content_view_environment: cv_id=2, env_id=
2023-05-23T08:57:48 [W|app|6374a493] Action failed
2023-05-23T08:57:48 [I|app|6374a493] Backtrace for ‘Action failed’ error (ActiveModel::UnknownAttributeError): unknown attribute ‘content_view_id’ for Katello::Host::ContentFacet.

As already mentioned it is only a hammer issue. I can change any host option within the GUI without any problem.

Best regards,
Thomas

Does it work if you also pass --lifecycle-environment "Library" to Hammer?

Unfortunately, no

This seems like a bug. However, If both of these are populated, I would expect it to work. Did it get an env_id when you passed the environment to Hammer? (also, my Hammer syntax is from memory and may be wrong, so best to double-check)

Yes, I get an env_id

set_up_content_view_environment: cv_id=2, env_id=4

New problem found… Foreman 3.6.1 saving host group deletes options Maybe it has the same reason?

Regards,
Tom

Opened Bug #36440: hammer host update fails with "unknown attribute ‘content_view_id’ for Katello::Host::ContentFacet" when you pass a content view / LCE - Katello - Foreman

:+1:

Hello Again,

I have installed the current version Foreman 3.7 with Katello 4.9. The Bug #36440 is still existing in this version. Why?

Best regards,
Tom