Description of problem: API/Hammer show different results then Webui Version-Release number of selected component (if applicable): Satellite 6.2.8 How reproducible: 100% Steps to Reproduce: 1) Create a new hostgroup without specifying architecture or OS: # hammer hostgroup create --name "AXE" --organizations "Default Organization" 2) Check it via API: # curl -X GET -s -k -u user:pass "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool ~~~ { "page": 1, "per_page": 200, "results": [ { "ancestry": null, "architecture_id": null, "architecture_name": null, "compute_profile_id": null, "compute_profile_name": null, "created_at": "2017-03-27 07:28:51 UTC", "domain_id": null, "domain_name": null, "environment_id": null, "environment_name": null, "id": 1, "medium_id": null, "medium_name": null, "name": "AXE", "operatingsystem_id": null, "operatingsystem_name": null, "parent_id": null, "parent_name": null, "ptable_id": null, "ptable_name": null, "puppet_ca_proxy_id": null, "puppet_proxy_id": null, "realm_id": null, "realm_name": null, "subnet_id": null, "subnet_name": null, "title": "AXE", "updated_at": "2017-03-27 07:28:51 UTC" } ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 1, "total": 1 } ~~~ Specify an arch / OS / Media / partition via webui and save it, this is the output from API: # curl -X GET -s -k -u user:pass "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool ~~~ { "page": 1, "per_page": 200, "results": [ { "ancestry": null, "architecture_id": 1, "architecture_name": "x86_64", "compute_profile_id": null, "compute_profile_name": null, "created_at": "2017-03-27 07:43:16 UTC", "domain_id": null, "domain_name": null, "environment_id": null, "environment_name": null, "id": 2, "medium_id": 11, "medium_name": "pipopopo/Library/Red_Hat_Server/Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_2", "name": "AXE", "operatingsystem_id": 1, "operatingsystem_name": "RedHat 7.2", "parent_id": null, "parent_name": null, "ptable_id": 72, "ptable_name": "CoreOS default fake", "puppet_ca_proxy_id": null, "puppet_proxy_id": null, "realm_id": null, "realm_name": null, "subnet_id": null, "subnet_name": null, "title": "AXE", "updated_at": "2017-03-27 07:45:05 UTC" } ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 1, "total": 1 } ~~~ 3) Reverting the action by removing the OS/Arch/Partition/Media via Webui Do API call to watch the results: # curl -X GET -s -k -u virt-who:virt-who "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool ~~~ { "page": 1, "per_page": 200, "results": [ { "ancestry": null, "architecture_id": null, "architecture_name": null, "compute_profile_id": null, "compute_profile_name": null, "created_at": "2017-03-27 07:43:16 UTC", "domain_id": null, "domain_name": null, "environment_id": null, "environment_name": null, "id": 2, "medium_id": null, "medium_name": null, "name": "AXE", "operatingsystem_id": 1, "operatingsystem_name": "RedHat 7.2", "parent_id": null, "parent_name": null, "ptable_id": null, "ptable_name": null, "puppet_ca_proxy_id": null, "puppet_proxy_id": null, "realm_id": null, "realm_name": null, "subnet_id": null, "subnet_name": null, "title": "AXE", "updated_at": "2017-03-27 08:32:04 UTC" } ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 1, "total": 1 } ~~~ To confirm I checked it also via hammer: # hammer hostgroup info --id 2 ~~~ [Foreman] Password for admin: Id: 2 Name: AXE Title: AXE Operating System: RedHat 7.2 Puppet CA Proxy Id: Puppet Master Proxy Id: Puppetclasses: Parameters: Organizations: pipopopo Parent Id: ~~~ Actual results: It seems that all the fields were reverted to null except for the Operating System. ~~~ "operatingsystem_id": 1, "operatingsystem_name": "RedHat 7.2", ~~~ Expected results: everything back to null as also shown in the Webui Additional info: This creates a discrepancy between hammer/API and what's seen in the webui.
Updated title, the issue is that when removing the architecture, the OS field becomes disabled and thus not sent, leading to the previous value being preserved. It isn't seen in the UI since if the architecture is blank the OS field is disabled on following views, but in the DB the hostgroup still has an OS defined. I have also noticed this behaviour for medium and partition table fields. Increasing severity and priority as this isn't just a cosmetic issue and may lead to unexpected results.
Created redmine issue http://projects.theforeman.org/issues/20347 from this bug
Upstream bug assigned to egilman
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20347 has been resolved.
Verified: @satellite 6.4.0 snap16 steps: 1) # hammer hostgroup create --name "AXE" --organizations "Default Organization" 2) # curl -X GET -s -k -u user:pass "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool 3) Specified an arch / OS / Media / partition via Webui 4) curl -X GET -s -k -u user:pass "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool 5) Reverted the action by removing the OS/Arch/Partition/Media via Webui 6) curl -X GET -s -k -u user:pass "https://localhost:443/api/v2/hostgroups/" | python -mjson.tool 7) hammer hostgroup info --id 2 Observation: - everything back to null as shown in the Webui (for both api/hammer) - API/Hammer shows same result as Webui
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2018:2927