Created attachment 1042491 [details] Output of foreman-debug from a Satellite 6.1.0 system running RHEL 7.1. Description of problem: It is possible to trigger an HTTP 500 error by issing an HTTP PUT request to `/api/v2/hosts/:id` and attempting to update any of the following attributes: * capabilities * puppet_class The following JSON messages are returned by the server: {"error": {"message":"unknown attribute: capabilities"}} {"error": {"message":"unknown attribute: puppet_class_ids"}} Here's a full example: >>> from nailgun import entities >>> host = entities.Host(id=13).read() >>> host.name = 'foo' >>> host.update_payload() { u'host': { 'architecture_id': 43, 'build': False, 'capabilities': [u'build'], 'compute_profile_id': None, 'compute_resource_id': None, 'domain_id': 60, 'enabled': True, 'environment_id': 228, 'host_parameters_attributes': [], 'hostgroup_id': None, 'id': 13, 'image_id': None, 'ip': None, 'location_id': 460, 'mac': u'd9:3e:f2:ba:fa:9a', 'managed': True, 'medium_id': 50, 'model_id': None, 'name': 'foo', 'operatingsystem_id': 66, 'organization_id': 459, 'owner_id': 3, 'owner_type': u'User', 'provision_method': u'build', 'ptable_id': 38, 'puppet_class_ids': [], 'puppet_proxy_id': None, 'realm_id': None, 'subnet_id': None, } } >>> response = host.update_raw() WARNING:nailgun.client:Received HTTP 500 response: { "error": {"message":"unknown attribute: capabilities"} } >>> fields = set(host.get_fields().keys()) >>> fields.remove('root_pass') >>> fields.remove('capabilities') >>> host.update_payload(fields) { u'host': { 'architecture_id': 43, 'build': False, 'compute_profile_id': None, 'compute_resource_id': None, 'domain_id': 60, 'enabled': True, 'environment_id': 228, 'host_parameters_attributes': [], 'hostgroup_id': None, 'id': 13, 'image_id': None, 'ip': None, 'location_id': 460, 'mac': u'd9:3e:f2:ba:fa:9a', 'managed': True, 'medium_id': 50, 'model_id': None, 'name': u'sdycruihg.fymn8dotb0', 'operatingsystem_id': 66, 'organization_id': 459, 'owner_id': 3, 'owner_type': u'User', 'provision_method': u'build', 'ptable_id': 38, 'puppet_class_ids': [], 'puppet_proxy_id': None, 'realm_id': None, 'subnet_id': None, } } >>> response = host.update_raw(fields) WARNING:nailgun.client:Received HTTP 500 response: { "error": {"message":"unknown attribute: puppet_class_ids"} } >>> fields.remove('puppet_class') >>> response = host.update_raw(fields) WARNING:nailgun.client:Received HTTP 422 response: { "error": {"id":13,"errors":{"provision_method":["can't be updated after host is provisioned"]},"full_messages":["Provision method can't be updated after host is provisioned"]} } >>> fields.remove('provision_method') >>> response = host.update_raw(fields) >>> response.status_code 200 Version-Release number of selected component (if applicable): Satellite 6.1.0. Foreman-debug is attached. How reproducible: 100% Steps to Reproduce: 1. See "Description of problem" section. 2. 3. Actual results: See "Description of problem" section. Expected results: See "Description of problem" section. Additional info:
Since this issue was entered in Red Hat Bugzilla, the release flag has been set to ? to ensure that it is properly evaluated for this release.
It's puppetclass_ids, not puppet_class_ids. upstream PR: https://github.com/theforeman/foreman/pull/3393 upstream bug: http://projects.theforeman.org/issues/14502
Marking assigned, since the upstream issue has a PR pending.
Connecting redmine issue http://projects.theforeman.org/issues/14502 from this bug
Moving to POST since upstream bug http://projects.theforeman.org/issues/14502 has been closed ------------- Anonymous Applied in changeset commit:8f9fdae35594632e94c73dcb5846d5409ebd34b9.
Failed QA in Satellite 6.2 Beta Snap 15.2 While the puppetclass_ids now work, we still get an error for "capabilities". { "error": { "message": "unknown attribute: capabilities" } }
One is not supposed to change capabilities, as that a computed field based on the compute resource used (e.g. if its bare metal - its only build based, if its ec2, its only image based, and if its rhev its both).
Would it be more accurate then to provide a better error message in case someone does provide a capabilities parameter? If this isn't the case then this part of the bug wouldn't matter since it is then an invalid input regardless.
in this case, I suggest to close this bug, and open a new one about a better server error when passing the capabilities bug.
Verified in Satellite 6.2 Beta Snap 18. puppetclass_ids work well now. I will file a separate bug for the capabilities error issue, since it is out of scope for this bug.
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/RHBA-2016:1501