Bug 1235041 - PUT /api/v2/hosts/:id returns HTTP 500 when updating "capabilities" or "puppet_class_ids"
Summary: PUT /api/v2/hosts/:id returns HTTP 500 when updating "capabilities" or "puppe...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: jcallaha
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-23 20:31 UTC by jaudet
Modified: 2019-11-14 06:46 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:09:16 UTC
Target Upstream Version:


Attachments (Terms of Use)
Output of foreman-debug from a Satellite 6.1.0 system running RHEL 7.1. (451.49 KB, application/x-xz)
2015-06-23 20:31 UTC, jaudet
no flags Details


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 14502 None None None 2016-04-06 11:31:03 UTC

Description jaudet 2015-06-23 20:31:36 UTC
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:

Comment 1 RHEL Program Management 2015-06-23 20:42:34 UTC
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.

Comment 3 Evgeni Golov 2016-04-06 11:25:48 UTC
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

Comment 4 Brad Buckingham 2016-04-06 13:14:17 UTC
Marking assigned, since the upstream issue has a PR pending.

Comment 5 Bryan Kearney 2016-04-06 13:23:49 UTC
Connecting redmine issue http://projects.theforeman.org/issues/14502 from this bug

Comment 6 Bryan Kearney 2016-04-08 12:06:54 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14502 has been closed
-------------
Anonymous
Applied in changeset commit:8f9fdae35594632e94c73dcb5846d5409ebd34b9.

Comment 7 jcallaha 2016-06-15 15:36:02 UTC
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"
  }
}

Comment 8 Ohad Levy 2016-06-16 07:31:14 UTC
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).

Comment 9 jcallaha 2016-06-21 13:30:27 UTC
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.

Comment 10 Ohad Levy 2016-06-23 05:38:41 UTC
in this case, I suggest to close this bug, and open a new one about a better server error when passing the capabilities bug.

Comment 11 jcallaha 2016-06-30 18:37:03 UTC
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.

Comment 12 Bryan Kearney 2016-07-27 11:09:16 UTC
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


Note You need to log in before you can comment on or make changes to this bug.