Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1235041

Summary: PUT /api/v2/hosts/:id returns HTTP 500 when updating "capabilities" or "puppet_class_ids"
Product: Red Hat Satellite Reporter: jaudet
Component: APIAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: bbuckingham, egolov, jcallaha, ohadlevy, sthirugn, stkachen
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/14502
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:09:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Output of foreman-debug from a Satellite 6.1.0 system running RHEL 7.1. none

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